จากการพัฒนาตอนนี้ผมใช้ super class โดยให้ทำงานที่ฟังก์ชั่น __init__ ก่อนหลังจากให้ให้เข้ามาทำงานต่อฟังก์ชั่นที่ 2 โดยเรียกแสดงผลชื่อไฟล์
โค้ด: เลือกทั้งหมด
# -*- coding: utf-8 -*-
import time
from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple
import os
import PythonMagick as Magick
class parent(object):
def __init__(self, up):
print childA()
def test(file):
img = Magick.Image('../img_magic/img_m/' + file)
img.quality(100)
img.magick('PNG')
img.write('../img_magic/img_m/' + file + '.png')
f = os.listdir("../img_magic/img_m")
for file in f:
print file
test(file)
class childA(parent):
def __init__(self):
super (childA, self).test()
childA()
import os
fee = os.listdir("../img_magic/img_m")
for fill in fee:
print fee
html = """
"""
def wsgi_app(self, environ, start_response):
request = Request(environ)
response = self.dispatch_request(request)
return response(environ, start_response)
def create_app(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return [parent + html + 'This time ----> ' + time.ctime()]
run_simple('127.0.0.1', 5012, create_app, use_debugger=True, use_reloader=True)