Flask Python Heroku

 lets start building source code

cd source # MyHerokuProject/source 

We need to create two files for heroku to spin up our application;

pip freeze > requirements.txt
cat >Procfile
web: python hello.py

create your index.html equivalent

cat >hello.py
import os
from flask import Flask
# import BeautifulSoup
import urllib2
import re

app = Flask(__name__)

@app.route('/')
def hello():
return 'Hello World!'

@app.route('/gb')
def goodbye():
return 'Good Bye'

if __name__ == '__main__':
# Bind to PORT if defined, otherwise default to 5000.
port = int(os.environ.get('PORT', 5000))
app.run(host='0.0.0.0', port=port)

and lets git it to heroku

git init 
git add .
git commit -m 'init'
heroku create
git push heroku master 

Leave a Reply

Your email address will not be published. Required fields are marked *