gpt4 book ai didi

Django WSGI 和 Gunicorn

转载 作者:行者123 更新时间:2023-12-01 14:02:51 25 4
gpt4 key购买 nike

这可能是一个非常愚蠢的问题;我正在尝试使用 Gunicorn 部署 Django 应用程序。但是,我刚刚创建了如下所示的 wsgi.py(wsgi.py 在我的根项目文件夹中):

import os

os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myproject.settings")

# This application object is used by any WSGI server configured to use this
# file. This includes Django's development server, if the WSGI_APPLICATION
# setting points here.
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()

# Apply WSGI middleware here.
# from helloworld.wsgi import HelloWorldApplication
# application = HelloWorldApplication(application)

现在我跑了:

python manage.py run_gunicorn

Gunicorn 会自动获取这个 wsgi.py 吗?这是如何运作的? (不确定 wsgi 在做什么)。或者我需要指定一些东西吗?

最佳答案

如果您在 Django 设置模块的 INSTALLED_APPS 中列出了 gunicorn,则命令为:

python manage.py run_gunicorn

不是你给出的命令。

关于Django WSGI 和 Gunicorn,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12066441/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com