Merge branch 'master' of github.com:NyxiumYuuki/FlaskALED

This commit is contained in:
MiharyR 2022-01-12 18:18:49 +01:00
commit d556784983
3 changed files with 8 additions and 10 deletions

View file

@ -1,9 +1,8 @@
from application import create_app from application import create_app
import os import os
app = create_app() app = create_app(os.environ.get('FLASK_ENV', None))
if __name__ == "__main__": if __name__ == "__main__":
PORT = os.environ.get('PORT', 33507) PORT = os.environ.get('PORT', 33507)
print('app.run')
app.run(host='0.0.0.0', port=PORT, DEBUG=True) app.run(host='0.0.0.0', port=PORT, DEBUG=True)

View file

@ -6,14 +6,13 @@ import os
db = SQLAlchemy() db = SQLAlchemy()
def create_app(): def create_app(flask_env='development'):
app = Flask(__name__, instance_relative_config=False) app = Flask(__name__, instance_relative_config=False)
FLASK_ENV = os.environ.get('FLASK_ENV', None) if flask_env == 'production':
if FLASK_ENV == 'production':
app.config.from_object("config.ProductionConfig") app.config.from_object("config.ProductionConfig")
elif FLASK_ENV == 'staging': elif flask_env == 'testing':
app.config.from_object("config.StagingConfig") app.config.from_object("config.TestingConfig")
elif FLASK_ENV == 'development': elif flask_env == 'development':
app.config.from_object("config.DevelopmentConfig") app.config.from_object("config.DevelopmentConfig")
else: else:
app.config.from_object("config.Config") app.config.from_object("config.Config")

View file

@ -30,8 +30,8 @@ class ProductionConfig(Config):
SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_TRACK_MODIFICATIONS = False
class StagingConfig(Config): class TestingConfig(Config):
STAGING = True TESTING = True
SQLALCHEMY_ECHO = False SQLALCHEMY_ECHO = False
SQLALCHEMY_TRACK_MODIFICATIONS = False SQLALCHEMY_TRACK_MODIFICATIONS = False