Prepare for Heroku deployment

This commit is contained in:
Xevion
2022-03-28 16:57:34 -05:00
parent 7753ef4488
commit ab7641b43e
2 changed files with 16 additions and 2 deletions

1
Procfile Normal file
View File

@@ -0,0 +1 @@
web: gunicorn create-app:app

View File

@@ -1,3 +1,4 @@
import os
import random
from datetime import datetime
@@ -16,10 +17,16 @@ db = SQLAlchemy()
def create_app():
app = Flask(__name__)
app.config['SECRET_KEY'] = 'secret key goes here'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
if app.config['ENV'] == 'development':
app.config['SECRET_KEY'] = 'secret key goes here'
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.sqlite'
if app.config['ENV'] == 'production':
app.config['SECRET_KEY'] = os.getenv('SECRET_KEY')
app.config['SQLALCHEMY_DATABASE_URI'] = os.getenv('DATABASE_URL')
db.init_app(app)
login_manager = LoginManager()
@@ -110,3 +117,9 @@ def create_app():
db.create_all(app=app)
return app
# Only used for Heroku; use 'flask run' or internal IDE configurations otherwise
if __name__ == '__main__':
app = create_app()
app.run()