gunicorn - 使用 Gunicorn 在与 / 不同的路径中加载 Pyramid 应用程序
问题描述
我有一个使用 Gunicorn 加载的 Pyramid 应用程序。我的ini文件有以下内容:
[app:main]
use = egg:my_example
...
[server:main]
use = egg:gunicorn
host = localhost
port = 5900
workers = 1
worker_class = gevent
我用 Gunicorn 启动:
gunicorn --paste ./development.ini
所以我的应用程序可以在http://127.0.0.1:5900
我需要做什么才能使我的应用程序在其他路径而不是 / 中可用,例如在http://127.0.0.1:5900/my_example
我看到了以下帖子: pyramid pserve in different root path than / 和Pyramid: how to set SCRIPT_NAME in request.environ但我仍然无法做到
解决方案
如果您希望所有传入的 url 从它们中删除前缀(例如,http://127.0.0.1:5900/my_example/foo/bar
导航到/foo/bar
应用程序中的路由),Rutter 是正确的答案。这似乎是您所描述的,并且https://stackoverflow.com/a/43506460/704327中的 ini 片段应该足够了。Rutter 还将正确地准备环境,以便您的应用程序/my_example
在使用request.route_path
and时生成带有前缀的正确 url request.route_url
。
推荐阅读
- c++ - 有没有办法使用 Johnny-5 发送 C/C++ 命令?
- dialogflow-es - 如何在 Dialogflow 中捕获用户的自由言论?
- python - Python将上下文添加到循环中的日志记录
- r - 更改堆叠 Geom_Bar 的顺序
- ruby-on-rails-5 - ruby gem audited 不记录 created_at 和 updated_at
- mysql - 如何编辑整个数据库中一行的值
- javascript - 如何验证表单中的多封电子邮件?
- javascript - 从 html input="date" 到 html 选择下拉格式
- python-3.x - 使用自定义简历在 Sklearn 中进行交叉验证
- html - 我的代码和命令中有 crud 问题