Heroku_flask_搭建與使用
Contents
[NOTE] Updated April 25, 2022. This article may have outdated content or subject matter.
Install heroku CLI
sudo snap install heroku --classic
setup account
heroku login
Create app
heroku create
Create a new Git repository
cd my-project/
git init
heroku git:remote -a name
Existing Git repository
heroku git:remote -a name
FLASK DEMO
app.py
from flask import Flask
app = Flask(__name__)
@app.route("/who")
def who_am_i():
return "w0x7ce"
if __name__ == '__main__':
app.run(port=5000)
wsgi.py
from app import app
if __name__ == "__main__":
app.run()
Procfile
web: gunicorn wsgi:app
gen requirements.txt
pip freeze >requirements.txt
Develop
git add .
git commit -m "update"
git push heroku master
View logs
heroku logs --tail
Author w0x7ce
LastMod 2022-04-25