Python 在heroku上部署时,Flask应用程序中出现H10错误

Python 在heroku上部署时,Flask应用程序中出现H10错误,python,flask,heroku,Python,Flask,Heroku,我的应用程序在本地主机上运行良好,但在heroku上部署我的flask应用程序时出现以下错误 2020-07-01T09:56:02.982007+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=webscrappingapp.herokuapp.com request_id=59cec0a7-98a3-49d8-b980-779cada

我的应用程序在本地主机上运行良好,但在heroku上部署我的flask应用程序时出现以下错误

2020-07-01T09:56:02.982007+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=webscrappingapp.herokuapp.com request_id=59cec0a7-98a3-49d8-b980-779cada2c0d9 fwd="103.40.197.230" dyno= connect= service= status=503 bytes= protocol=https
2020-07-01T09:56:03.765421+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=webscrappingapp.herokuapp.com request_id=b2ddd2b8-5930-4049-993d-3c8e972b10ee fwd="103.40.197.230" dyno= connect= service= status=503 bytes= protocol=https
烧瓶锉, 废话--

程序文件:

web : gunicorn webscrap:app
Requirements.txt:

autopep8==1.5.3
beautifulsoup4==4.9.1
certifi==2020.6.20
chardet==3.0.4
click==7.1.1
Flask==1.1.2
gunicorn==20.0.4
idna==2.10
itsdangerous==1.1.0
Jinja2==2.11.2
MarkupSafe==1.1.1
pycodestyle==2.6.0
pytz==2020.1
requests==2.24.0
soupsieve==2.0.1
toml==0.10.1
urllib3==1.25.9
Werkzeug==1.0.1
我尝试将Procfile内容替换为

web : gunicorn --bind 0.0.0.0:$PORT webscrap:app
但这对我不起作用。我还尝试用
server
替换
app
,但没有成功。因此,请为这个问题提出解决方案

编辑: 我的错误是文件中的空格。正确的一个是--

但现在我遇到了H14错误,我还尝试在Procfile中添加了
heroku ps:scale web=1
,但对我无效。

将Procfile txt更改为

web: uwsgi uwsgi.ini
创建新文件uwsgi.ini并添加此代码

[uwsgi]
http-socket = :$(PORT)
master = true
die-on-term = true
module = app:app
memory-report = true
在requirement.txt中添加uwsgi

...
urllib3==1.25.9
Werkzeug==1.0.1
uwsgi
添加runtime.txt并添加此文本

python-version
例如python-3.7.4

我的项目结构

创建Procfile-在其中写入以下行
web:gunicorn main:app
其中“main”是提到app=create\u app()的文件名

pip安装gunicorn

pip freeze>requirements.txt

再创建一个名为
runtime.txt
的文件,其中包含以下行
python-3.9.2
(提供项目的相应python版本)

Heroku部分:使用gitbash或vscode控制台逐个运行以下命令

heroku登录

git init

git添加。

git提交-am“Initial commit”


git-push-heroku-main

我不确定是否使用
gunicorn
执行此操作,但在heroku上无法在调试模式下运行Flask<代码>应用程序运行(debug=True)。应为
False
或省略。您还可以在那里指定一个端口
app.run(port=os.environ.get(“port”,8080))
(如果存在,将绑定到
port
,否则使用端口8080)也可以尝试在没有gunicorn的情况下运行您的Flask应用程序,并希望获得更多有意义的错误消息。否,我没有runtime.txt文件。我还需要包含.flaskenv文件吗?不,不需要添加.env文件。如何将应用部署到Herokokay,
git add.
-->
git commit-m“message”
-->
heroku create WebScrapingApp
-->
git push heroku master
我也遇到了这个解决方案
port=int(os.environ.get(“port”,5000))app.run(host='0.0.0.0',port=port,debug=True)
,这有帮助吗?
...
urllib3==1.25.9
Werkzeug==1.0.1
uwsgi
python-version