WSGI协议 Web Server Gateway Interface 网关接口协议
uWSGI ---> 作用:接收请求
uWSGI <---> WSGI(语言,媒介) <---> webpy 服务器与框架之间的通信
三大组件
1 Application
类和函数分别构建协议
# -*- encoding: UTF-8 -*-
from wsgiref.simple_server import make_server
HELLO_WORLD = b'Hello,World!\n'
def simple_app(environ, start_response):
status = '200 OK'
response_header = [('Content-type','text/plain')]
start_response(status,response_header)
return [HELLO_WORLD]
class AppClass:
def __call__(self,environ,start_response):
status = '200 OK'
response_header = [('Content-type','text/plain')]
start_response(status,response_header)
return [HELLO_WORLD]
server = make_server('192.168.1.41',8080,app=AppClass())
# 启动服务
server.serve_forever()