# simple-wsgi-app **Repository Path**: yazutang/simple-wsgi-app ## Basic Information - **Project Name**: simple-wsgi-app - **Description**: No description available - **Primary Language**: Python - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-12-13 - **Last Updated**: 2021-12-13 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # simple-wsgi-app #### 说明 WSGI是一种规范,是WEB服务器和PYTHON Web框架之间的一个标准接口 它的一个额外的作用是在处理请求之前和之后提供中间件支持 服务器必须提供两个东西,一个环境字典(environ,包含HTTP请求头信息),还有一个是开始响应(start_response)函数 start_response有两个参数,一个是status包含标准的HTTP状态码字符串像200 OK,和response_headers 响应头-标准HTTP响应头元组列表 application必须返回一个可迭代的字节串。 ```python def application(environ, start_response): status = '200 OK' response_headers = [('Content-Type', 'text/plain')] start_response(status, response_headers) return [b'hello world'] ``` #### 使用 ```bash $ python demo_app.py # 访问 http://127.0.0.1:8000 即可 ``` #### 详情 https://www.python.org/dev/peps/pep-0333/ https://www.python.org/dev/peps/pep-3333/