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

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端也使用函數來實現(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ī)范的介紹,希望對大家有所幫助。更多編程基礎知識學習:python創(chuàng)新互聯(lián)教程
本文教程操作環(huán)境:windows7系統(tǒng)、Python 3.9.1,DELL G3電腦。
分享文章:創(chuàng)新互聯(lián)Python教程:pythonWSGI規(guī)范是什么
瀏覽路徑:http://m.fisionsoft.com.cn/article/djdidjj.html


咨詢
建站咨詢
