Heroku代码H10路径“ /”和“ /favicon.ico”上带有Gunicorn的服务烧瓶+ React App

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

我尝试使用Gunicorn的Flask api服务于香草React应用(使用create-react-app创建,没有进一步的修改-只是创建了react应用并按原样构建),但是在Heroku上使用代码H10失败。我无法查明应用程序为什么失败。在本地工作正常。不知道是否可能是原因,我在本地使用了虚拟环境(venv)。任何想法为什么会失败?谢谢!

下面的Heroku日志中的错误。

2020-06-13T03:20:19.425468+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testdeployd.herokuapp.com request_id=302fe53f-2346-4c31-bf69-a6411da8a7b1 fwd="173.68.90.222" dyno= connect= service= status=503 bytes= protocol=https
2020-06-13T03:20:19.806856+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=testdeployd.herokuapp.com request_id=ea82a928-dcab-4931-a60b-8d63f4417c0a fwd="173.68.90.222" dyno= connect= service= status=503 bytes= protocol=https
2020-06-13T03:20:20.166173+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=testdeployd.herokuapp.com request_id=3c673c5f-ad5f-466d-92b0-830cdaff4f48 fwd="173.68.90.222" dyno= connect= service= status=503 bytes= protocol=https

目录结构在下面。

myapp
 |->api
     |->api.py
     |->.flasenv
     |->venv
 |->build
 |->node_modules
 |->public
 |->src
 ...
 |->Procfile
 |->requirements.txt

api.py的内容如下。

import flask

app = flask.Flask(__name__, static_folder="../build", static_url_path="/")


@app.route("/")
def index():
    return app.send_static_file("index.html")

我在Procfile中放入了以下内容。

web: gunicorn -b :5000 --pythonpath api api:app

添加了以下package.json文件。

"proxy": "http://localhost:5000"
python reactjs flask heroku gunicorn
1个回答
0
投票

这里是一个例子

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