首页 > 解决方案 > 如何使用 Flask 在 python App Engine 应用程序中增加 gunicorn --limit-request-line?

问题描述

这是一个排序问题,我正在 Google Cloud Platform 中使用 python 运行时和 Flask 构建一个非常简单的 API。问题是请求 URL 可能会有点长(大约 6000 字节)并且当前的 gunicorn 限制是 4096。我知道这听起来很愚蠢,但我试图在 app.yaml 文件上更改它,当我运行它时返回 500 服务器错误。我几乎可以肯定这是我添加的入口点中的一个问题,因为我不知道如何修改 app.yaml(我是 Web 开发的新手)。我的 app.yaml 如下:

runtime: python37
service: py
entrypoint: gunicorn --limit-request-line 8190 main:app

如果你知道我有什么错误,有人可以帮助我吗?我检查了 GCP 文档和演示,但像往常一样,它们的描述性不是很好。

标签: pythongoogle-app-engineflaskgunicorn

解决方案


You may need to have gunicorn in your requirements.txt if you don't have it already, as the docs mention.

Regarding the entrypoint in your app.yaml it looks correct, however I think you're missing adding the port to have App Engine listening to 8080, which is a requirement.

entrypoint: gunicorn -b :8080 --limit-request-line 8190 main:app

More information can be found as well in the following section of the documentation.


推荐阅读