掃二維碼與項(xiàng)目經(jīng)理溝通
我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
1、WSGI協(xié)議規(guī)定,Application端需要成為可調(diào)用目標(biāo)(函數(shù)、類別等)。

def simple_app(environ, start_response):
status = '200 OK'
response_headers = [('Content-type', 'text/plain')]
start_response(status, response_headers)
return ['Hello world!\n']2、Server端也使用函數(shù)來實(shí)現(xiàn)。
import os
def wsgi_server(application):
environ = dict(os.environ.items())
def start_response(status, response_headers):
print(f'status: {status}')
print(f'response_headers: {response_headers}')
result = application(environ, start_response)
for data in result:
print(f'response_body: {data}')以上就是python WSGI規(guī)范的介紹,希望對(duì)大家有所幫助。更多編程基礎(chǔ)知識(shí)學(xué)習(xí):python創(chuàng)新互聯(lián)教程
本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。

我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流