mkdir project
virtualenv --no-site-packages project
cd project
source bin/activate
pip install Flask gunicorn psycopg2 peewee
git init
heroku create
heroku addons:create heroku-postgresql:hobby-dev
export DATABASE_URL=$(heroku config:get DATABASE_URL)
Created
May 21, 2015 20:52
-
-
Save emilyhorsman/66e3f6b8f0ca7508ae47 to your computer and use it in GitHub Desktop.
Setting up Heroku/Python/postgres/Flask
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
import os | |
from flask import Flask | |
from playhouse.flask_utils import FlaskDB | |
DATABASE = os.environ["DATABASE_URL"] | |
app = Flask(__name__) | |
app.config.from_object(__name__) | |
database = FlaskDB(app) |
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
from app import app, database | |
from models import Foo | |
from views import * | |
if __name__ == "__main__": | |
database.database.create_table([Foo], safe=True) | |
app.run() |
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
from playhouse.flask_utils import FlaskDB | |
from peewee import * | |
from app import database | |
class Foo(database.Model): | |
text = CharField() |
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
web: gunicorn main:app --log-file=- |
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
from app import app | |
from models import Foo | |
@app.route("/") | |
def index(): | |
return "bar" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment