新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷(xiāo)解決方案
創(chuàng)新互聯(lián)Python教程:pythonWSGI規(guī)范是什么
1、WSGI協(xié)議規(guī)定,Application端需要成為可調(diào)用目標(biāo)(函數(shù)、類(lèi)別等)。

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ù)來(lái)實(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電腦。
名稱(chēng)欄目:創(chuàng)新互聯(lián)Python教程:pythonWSGI規(guī)范是什么
網(wǎng)站地址:http://www.dlmjj.cn/article/djdidjj.html


咨詢(xún)
建站咨詢(xún)
