Load a Pyramid App with Gunicorn in a different path than /

时间:2019-02-23 22:44:40

标签: gunicorn pyramid

I have a Pyramid application that I am loading with Gunicorn. My ini file has the following:

[app:main]
use = egg:my_example
...
[server:main]
use = egg:gunicorn
host = localhost
port = 5900
workers = 1
worker_class = gevent

I start Gunicorn witn:

gunicorn --paste ./development.ini

So my application is available at http://127.0.0.1:5900

What do I need to to do so my application is available in other path rather than / ,for example at http://127.0.0.1:5900/my_example

I saw the following posts: pyramid pserve in different root path than / and Pyramid: how to set SCRIPT_NAME in request.environ but I'm still not able to do it

1 个答案:

答案 0 :(得分:0)

如果您希望所有传入的URL都只删除前缀,那么

Rutter是正确的答案(例如,http://127.0.0.1:5900/my_example/foo/bar导航至应用程序中的/foo/bar路由)。这似乎就是您要描述的内容,https://stackoverflow.com/a/43506460/704327中的ini代码段就足够了。 Rutter还将正确准备环境,以便在使用/my_examplerequest.route_path时,您的应用将生成带有request.route_url前缀的正确URL。

相关问题