mirror of
https://github.com/Xevion/runnerspace.git
synced 2025-12-07 09:16:21 -06:00
Prepare for Heroku deployment
This commit is contained in:
@@ -1,3 +1,4 @@
|
|||||||
|
import os
|
||||||
import random
|
import random
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
|
||||||
@@ -16,10 +17,16 @@ db = SQLAlchemy()
|
|||||||
def create_app():
|
def create_app():
|
||||||
app = Flask(__name__)
|
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
|
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)
|
db.init_app(app)
|
||||||
|
|
||||||
login_manager = LoginManager()
|
login_manager = LoginManager()
|
||||||
@@ -110,3 +117,9 @@ def create_app():
|
|||||||
db.create_all(app=app)
|
db.create_all(app=app)
|
||||||
|
|
||||||
return app
|
return app
|
||||||
|
|
||||||
|
|
||||||
|
# Only used for Heroku; use 'flask run' or internal IDE configurations otherwise
|
||||||
|
if __name__ == '__main__':
|
||||||
|
app = create_app()
|
||||||
|
app.run()
|
||||||
|
|||||||
Reference in New Issue
Block a user