适用场景
Python 的 WSGI HTTP 服务器。 本条为命令参考与排查示例;请先确认命令已安装,再按示例定位实际参数和输出。
gunicorn
Python 的 WSGI HTTP 服务器。 更多信息:https://manned.org/gunicorn。
- 运行 Python web 应用程序:
gunicorn {{导入路径:应用程序}}
- 在 localhost 上监听 8080 端口:
gunicorn {{[-b|--bind]}} localhost:8080 {{导入路径:应用程序}}
- 启用实时自动加载:
gunicorn --reload {{导入路径:应用程序}}
- 使用 4 个工作进程处理请求:
gunicorn {{[-w|--workers]}} 4 {{导入路径:应用程序}}
- 使用 4 个工作线程处理请求:
gunicorn --threads 4 {{导入路径:应用程序}}
- 通过 HTTPS 运行应用程序:
gunicorn --certfile {{cert.pem}} --keyfile {{key.pem}} {{导入路径:应用程序}}