You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DjangoBlog-Maintenance-Anal.../src/wsgi.py

28 lines
1.4 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

"""
WSGI config for djangoblog project.
Django博客项目的WSGI配置文件
WSGIWeb Server Gateway Interface是Web服务器与Python Web应用之间的通信标准
负责将Web服务器如Nginx、Apache接收的HTTP请求转发给Django应用再将应用响应返回给服务器
It exposes the WSGI callable as a module-level variable named ``application``.
该文件将WSGI可调用对象处理请求的核心入口暴露为模块级变量命名为`application`
Web服务器通过调用这个`application`对象与Django应用交互
For more information on this file, see
https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
"""
# 导入Python内置的os模块用于读取环境变量、处理路径等
import os
# 导入Django的WSGI应用生成器根据项目配置创建WSGI可调用对象
from django.core.wsgi import get_wsgi_application
# 设置Django项目的配置模块环境变量
# 告诉Django使用哪个settings文件此处为项目根目录下的djangoblog.settings
# 生产环境中可通过服务器配置修改该环境变量,切换不同配置(如生产/测试配置)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "djangoblog.settings")
# 创建WSGI应用对象Django根据上述配置生成处理HTTP请求的核心入口
# Web服务器如Gunicorn、uWSGI会加载这个`application`对象来运行项目
application = get_wsgi_application()