Skip to content
Snippets Groups Projects
Commit ae806598 authored by Bo-Chun Chen's avatar Bo-Chun Chen
Browse files

Updated to prevent loading config file in production

parent dec9b015
No related branches found
No related tags found
No related merge requests found
...@@ -4,6 +4,7 @@ from flask_sqlalchemy import SQLAlchemy ...@@ -4,6 +4,7 @@ from flask_sqlalchemy import SQLAlchemy
from flask_login import LoginManager from flask_login import LoginManager
from flask_migrate import Migrate from flask_migrate import Migrate
from flask_bootstrap import Bootstrap from flask_bootstrap import Bootstrap
import os
# local imports # local imports
from config import app_config from config import app_config
...@@ -13,9 +14,16 @@ db = SQLAlchemy() ...@@ -13,9 +14,16 @@ db = SQLAlchemy()
login_manager = LoginManager() login_manager = LoginManager()
def create_app(config_name): def create_app(config_name):
app = Flask(__name__, instance_relative_config=True) if os.getenv('FLASK_ENV') == "production":
app.config.from_object(app_config[config_name]) app = Flask(__name__)
app.config.from_pyfile('config.py') app.config.update(
SECRET_KEY=os.getenv('SECRET_KEY'),
SQLALCHEMY_DATABASE_URI=os.getenv('SQLALCHEMY_DATABASE_URI')
)
else:
app = Flask(__name__, instance_relative_config=True)
app.config.from_object(app_config[config_name])
app.config.from_pyfile('config.py')
db.init_app(app) db.init_app(app)
login_manager.init_app(app) login_manager.init_app(app)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment