【说站】python WSGI规范是什么
python WSGI规范是什么
1、WSGI协议规定,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端也使用函数来实现。
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规范的介绍,希望对大家有所帮助。更多编程基础知识学习:python学习网
本文教程操作环境:windows7系统、Python 3.9.1,DELL G3电脑。
本站发布的内容若侵犯到您的权益,请邮件联系站长删除,我们将及时处理!
从您进入本站开始,已表示您已同意接受本站【免责声明】中的一切条款!
本站大部分下载资源收集于网络,不保证其完整性以及安全性,请下载后自行研究。
本站资源仅供学习和交流使用,版权归原作者所有,请勿商业运营、违法使用和传播!请在下载后24小时之内自觉删除。
若作商业用途,请购买正版,由于未及时购买和付费发生的侵权行为,使用者自行承担,概与本站无关。