【问题标题】:Load a Pyramid App with Gunicorn in a different path than /使用 Gunicorn 在与 / 不同的路径中加载 Pyramid 应用程序
【发布时间】:2019-02-27 04:40:55
【问题描述】:

我有一个使用 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,但我还是做不到

【问题讨论】:

    标签: gunicorn pyramid


    【解决方案1】:

    如果您希望所有传入的 url 从它们中删除前缀(例如,http://127.0.0.1:5900/my_example/foo/bar 导航到应用程序中的 /foo/bar 路由),Rutter 是正确的答案。这似乎就是您所描述的,https://stackoverflow.com/a/43506460/704327 中的 ini sn-p 应该足够了。 Rutter 还将正确地准备环境,以便您的应用在使用 request.route_pathrequest.route_url 时生成带有 /my_example 前缀的正确 url。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-07-20
      • 1970-01-01
      • 1970-01-01
      • 2013-01-22
      • 1970-01-01
      • 1970-01-01
      • 2021-11-15
      • 1970-01-01
      相关资源
      最近更新 更多