Created
February 20, 2020 06:37
-
-
Save e96031413/44d27297a994ccb805899a6dfcfcf7e0 to your computer and use it in GitHub Desktop.
Deploy Your Python Flask Web To Heroku
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Just a record of how to deploy flask to heroku | |
# original post from https://blog.heron.me/damn-simple-python-web-server-on-heroku-ba67cad2fb18 | |
# 1.Create a new project folder: | |
$ PROJECT=<WHATEVER YOUR PROJECT NAME> | |
$ mkdir $PROJECT && cd $PROJECT | |
# 2.Add requirements.txt inside: | |
Flask==1.0.3 | |
gunicorn==19.9.0 | |
# 3.Install them: | |
$ pip install -r requirements.txt | |
# 4.Write Code ( In the same folder, add main.py:) | |
from flask import Flask | |
app = Flask(__name__) | |
@app.route("/") | |
def hello(): | |
return "Hello World!" | |
# 5.add Procfile (this is used by Heroku to know how to run your code): | |
web: gunicorn main:app | |
# 6.Deploy on Heroku | |
# After installing heroku-cli and login, we initialize our folder as a git repo, create a Heroku app, | |
# then push our folder to that app via git: | |
$ git init && git add . && git commit -m "Initialize project" | |
$ heroku create $PROJECT | |
$ heroku git:remote -a $PROJECT | |
$ git push heroku master | |
# 7.Done! Your hello-world website should be live now at $PROJECT.herokuapp.com |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment