使用与Gunicorn不同的路径加载金字塔应用程序

问题描述 投票:0回答:1

我有一个金字塔应用程序,我正在加载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但我仍然无法做到

gunicorn pyramid
1个回答
0
投票

如果您希望所有传入的网址只是从中移除前缀(例如,http://127.0.0.1:5900/my_example/foo/bar导航到您应用中的/foo/bar路线),Rutter就是正确的答案。这似乎是你所描述的,而https://stackoverflow.com/a/43506460/704327中的ini片段应该足够了。 Rutter还将正确准备环境,以便您的应用程序在使用/my_examplerequest.route_path时生成带有request.route_url前缀的正确URL。

© www.soinside.com 2019 - 2024. All rights reserved.