【发布时间】:2020-08-18 10:16:57
【问题描述】:
我最近试图理解什么是 WSGI 应用程序:
一个 WSGI 应用程序只是一个可调用的对象,它传递了一个环境 - 一个包含请求数据的字典,以及一个被调用以开始发送响应的 start_response 函数。
为了向服务器发送数据,您只需调用 start_response 并返回一个可迭代对象。
所以,这是一个简单的应用程序:
def application(environ, start_response): start_response('200 OK', [('Content-Type', 'text/html')]) return ['Hello World!']
Django 的 wsgi.py 是
"""
WSGI config for basic_django project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/2.2/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'basic_django.settings')
application = get_wsgi_application()
但是当我看到 wsgi.py 时,application = get_wsgi_application() 可调用不会通过 environ 或 start_response 函数传递
那么如何理解这个
【问题讨论】: