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
import os
app = create_app()
app = create_app(os.environ.get('FLASK_ENV', None))
if __name__ == "__main__":
PORT = os.environ.get('PORT', 33507)
print('app.run')
app.run(host='0.0.0.0', port=PORT, DEBUG=True)

View file

@ -6,14 +6,13 @@ import os
db = SQLAlchemy()
def create_app():
def create_app(flask_env='development'):
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")
elif FLASK_ENV == 'staging':
app.config.from_object("config.StagingConfig")
elif FLASK_ENV == 'development':
elif flask_env == 'testing':
app.config.from_object("config.TestingConfig")
elif flask_env == 'development':
app.config.from_object("config.DevelopmentConfig")
else:
app.config.from_object("config.Config")

View file

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