我有一个金字塔应用程序,我正在加载Gunicorn。我的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但我仍然无法做到
如果您希望所有传入的网址只是从中移除前缀(例如,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
时生成带有request.route_url
前缀的正确URL。