โดย bom_002 » 14/03/2017 7:35 pm
Code
โค้ด: เลือกทั้งหมด
# -*- coding-utf-8 -*-
import time
from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple
html = """ tag html """
def wsgi_app(self, environ, start_response):
request = Response(environ)
response = self.dispatch_request(request)
return response(environ, start_response)
def create_app(environ, start_response):
start_response('200 OK',[('Content-Type'),'text/plain']) # planin html
return [html + 'this time ----> ' + time.ctime()]
run_simple('127.0.0.1', 5003, create_app, use_debugger=True, use_reloader=True)
ผลการรันผ่าน
- a6.png (4.99 KiB) Viewed 569 times
เมื่อไปทดสอบด้าน Server ไม่มีการแสดงค่า
- a7.png (3.23 KiB) Viewed 569 times
กลับมาดูผลการรัน แล้วมี Error แบบนี้ครับ
- a8.png (14.69 KiB) Viewed 569 times
แก้ไขยังไงครับ
[b][u]Code[/u][/b]
[code]
# -*- coding-utf-8 -*-
import time
from werkzeug.wrappers import Request, Response
from werkzeug.serving import run_simple
html = """ tag html """
def wsgi_app(self, environ, start_response):
request = Response(environ)
response = self.dispatch_request(request)
return response(environ, start_response)
def create_app(environ, start_response):
start_response('200 OK',[('Content-Type'),'text/plain']) # planin html
return [html + 'this time ----> ' + time.ctime()]
run_simple('127.0.0.1', 5003, create_app, use_debugger=True, use_reloader=True)[/code]
[b][u]ผลการรันผ่าน[/u][/b]
[attachment=2]a6.png[/attachment]
[u][b]เมื่อไปทดสอบด้าน Server ไม่มีการแสดงค่า[/b][/u]
[attachment=0]a7.png[/attachment]
[b][u]กลับมาดูผลการรัน แล้วมี Error แบบนี้ครับ[/u][/b]
[attachment=1]a8.png[/attachment]
แก้ไขยังไงครับ