Flask Heroku已部署,但应用程序错误

时间:2020-08-20 21:47:22

标签: python flask heroku

我已经在Heroku上部署了Flask应用程序,但是当我打开该应用程序时,出现以下错误:

An error occurred in the application and your page could not be served. 
If you are the application owner, check your logs for details. 
You can do this from the Heroku CLI with the command
heroku logs --tail

这是我的app.py

from flask import Flask, render_template
import base64, os

app = Flask(__name__)

@app.route("/")
@app.route("/home/")
def home():
    return render_template('home.html')

@app.route("/projects/")
def projects():
    return render_template('projects.html', title='Projects')

@app.route("/resume/", methods=["GET"])
def get_test_file():
    return render_template('resume.html', title='Resume')

if __name__ == '__main__':
    port = int(os.environ.get("PORT", 5000))
    app.run(debug=True, port=port)

我的Procfile

web: gunicorn -b :$PORT app:app

我的requirements.txt

click==7.1.2
Flask==1.1.2        
Frozen-Flask==0.15  
itsdangerous==1.1.0 
Jinja2==2.11.2      
MarkupSafe==1.1.1   
myapp==0.1.dev0     
Werkzeug==1.0.1  

日志:

-----> Python app detected
-----> Installing python-3.6.12
-----> Installing pip 20.1.1, setuptools 47.1.1 and wheel 0.34.2
-----> Installing SQLite3
-----> Installing requirements with pip
       Collecting click==7.1.2
         Downloading click-7.1.2-py2.py3-none-any.whl (82 kB)
       Collecting Flask==1.1.2
         Downloading Flask-1.1.2-py2.py3-none-any.whl (94 kB)
       Collecting Frozen-Flask==0.15
         Downloading Frozen_Flask-0.15-py2.py3-none-any.whl (20 kB)
       Collecting itsdangerous==1.1.0
         Downloading itsdangerous-1.1.0-py2.py3-none-any.whl (16 kB)
       Collecting Jinja2==2.11.2
         Downloading Jinja2-2.11.2-py2.py3-none-any.whl (125 kB)
       Collecting MarkupSafe==1.1.1
         Downloading MarkupSafe-1.1.1-cp36-cp36m-manylinux1_x86_64.whl (27 kB)
       Collecting myapp==0.1.dev0
         Downloading myapp-0.1dev.tar.gz (1.0 kB)
       Collecting Werkzeug==1.0.1
         Downloading Werkzeug-1.0.1-py2.py3-none-any.whl (298 kB)
       Building wheels for collected packages: myapp
         Building wheel for myapp (setup.py): started
         Building wheel for myapp (setup.py): finished with status 'done'
         Created wheel for myapp: filename=myapp-0.1.dev0-py3-none-any.whl size=1425 sha256=baa052aa1ff599e1acd18838d0c3ad438ae571d5e3e30b35a44b217539ff7504
         Stored in directory: /tmp/pip-ephem-wheel-cache-gz88y4ah/wheels/c8/d5/52/3d490595b8efdfd4f75c9b5f88600e7b538c91470afbeff917
       Successfully built myapp
       Installing collected packages: click, Werkzeug, MarkupSafe, Jinja2, itsdangerous, Flask, Frozen-Flask, myapp
       Successfully installed Flask-1.1.2 Frozen-Flask-0.15 Jinja2-2.11.2 MarkupSafe-1.1.1 Werkzeug-1.0.1 click-7.1.2 itsdangerous-1.1.0 myapp-0.1.dev0
-----> Discovering process types
       Procfile declares types -> web
-----> Compressing...
       Done: 45.5M
-----> Launching...
       Released v3
       https://ymericson.herokuapp.com/ deployed to Heroku

我很困惑,因为我没有在日志中看到错误,并且能够部署,但是当我打开该应用程序时,我遇到了这个应用程序错误。

更新:这是运行时日志:

2020-08-21T18:28:20.209372+00:00 app[api]: Release v1 created by user [email]@gmail.com
2020-08-21T18:28:20.209372+00:00 app[api]: Initial release by user [email]@gmail.com
2020-08-21T18:28:21.560600+00:00 app[api]: Release v2 created by user [email]@gmail.com
2020-08-21T18:28:21.560600+00:00 app[api]: Enable Logplex by user [email]@gmail.com
2020-08-21T18:29:43.000000+00:00 app[api]: Build started by user [email]@gmail.com
2020-08-21T18:30:09.148132+00:00 app[api]: Release v3 created by user [email]@gmail.com
2020-08-21T18:30:09.148132+00:00 app[api]: Deploy 8d0cb456 by user [email]@gmail.com
2020-08-21T18:30:09.161818+00:00 app[api]: Scaled to web@1:Free by user [email]@gmail.com
2020-08-21T18:30:12.160085+00:00 heroku[web.1]: Starting process with command `gunicorn -b :51336 app:app`
2020-08-21T18:30:14.056430+00:00 app[web.1]: bash: gunicorn: command not found
2020-08-21T18:30:14.100494+00:00 heroku[web.1]: Process exited with status 127
2020-08-21T18:30:14.139817+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-21T18:30:14.143878+00:00 heroku[web.1]: State changed from crashed to starting
2020-08-21T18:30:17.000000+00:00 app[api]: Build succeeded
2020-08-21T18:30:17.438400+00:00 heroku[web.1]: Starting process with command `gunicorn -b :38034 app:app`
2020-08-21T18:30:19.910279+00:00 app[web.1]: bash: gunicorn: command not found
2020-08-21T18:30:19.973120+00:00 heroku[web.1]: Process exited with status 127
2020-08-21T18:30:20.022907+00:00 heroku[web.1]: State changed from starting to crashed
2020-08-21T18:30:21.234577+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=ymericson.herokuapp.com request_id=76feb50e-a6e3-4699-93fb-c2888f0a3b6e fwd="74.96.140.110" dyno= connect= service= status=503 bytes= protocol=https
2020-08-21T18:30:21.564716+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=ymericson.herokuapp.com request_id=e9316de5-0f64-4a2e-87e4-42d695e0d81d fwd="74.96.140.110" dyno= connect= service= status=503 bytes= protocol=https

更新2:

愚蠢的我。我在gunicorn==20.0.4上添加了requirements.txt,并且有效。

0 个答案:

没有答案