文章目录
python WSGI
一、WSGI
1.定义
WSGI是Web Server Gateway Interface的简称。它不是服务器,python模块,框架,API和任何种类的软件。它仅仅是一个服务器和应用间的接口规范。
二、运行WSGI服务
写一个server.py
# server.py
# 从wsgiref模块导入:
from wsgiref.simple_server import make_server
# 导入我们自己编写的application函数:
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return [b'<h1>hello world!</h1>']
a=8080
httpd=make_server('',a,application)
httpd.serve_forever()
运行
在浏览器上输入 http://localhost:8080/可以看到结果