ลองเขียน Framework ทดสอบการเชื่อมต่อ Server แล้วเกิด Error แก้ไขยังไงครับ

ตอบกระทู้

รูปแสดงอารมณ์
:icon_plusone: :like: :plusone: :gfb: :-D :) :( :-o 8O :? 8) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :!: :?: :idea: :arrow: :| :mrgreen: :angry: :baa: :biggrin:
รูปแสดงอารมณ์อื่นๆ

BBCode เปิด
[img] เปิด
[url] เปิด
[Smile icon] เปิด

กระทู้แนะนำ
   

มุมมองที่ขยายได้ กระทู้แนะนำ: ลองเขียน Framework ทดสอบการเชื่อมต่อ Server แล้วเกิด Error แก้ไขยังไงครับ

Re: ลองเขียน Framework ทดสอบการเชื่อมต่อ Server แล้วเกิด Error แก้ไขยังไงครับ

โดย bom_002 » 18/03/2017 9:33 am

ใช้ได้แล้วครับ ขอบคุณครับ

Re: ลองเขียน Framework ทดสอบการเชื่อมต่อ Server แล้วเกิด Error แก้ไขยังไงครับ

โดย mindphp » 14/03/2017 7:44 pm

ลองแก้จาก

โค้ด: เลือกทั้งหมด

start_response('200 OK',[('Content-Type'),'text/plain'])  # planin  html
เป็น

โค้ด: เลือกทั้งหมด

start_response('200 OK',[('Content-Type','text/plain')])  # planin  html

ลองเขียน Framework ทดสอบการเชื่อมต่อ Server แล้วเกิด Error แก้ไขยังไงครับ

โดย 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
a6.png (4.99 KiB) Viewed 569 times
เมื่อไปทดสอบด้าน Server ไม่มีการแสดงค่า
a7.png
a7.png (3.23 KiB) Viewed 569 times
กลับมาดูผลการรัน แล้วมี Error แบบนี้ครับ
a8.png
a8.png (14.69 KiB) Viewed 569 times
แก้ไขยังไงครับ

ข้างบน