Fix: Server startup error due to configuration type not being assigned correctly.
This commit is contained in:
2
app.py
2
app.py
@@ -73,7 +73,6 @@ app = Flask(__name__)
|
|||||||
app.config.from_object(app_config) # for db init with required keys
|
app.config.from_object(app_config) # for db init with required keys
|
||||||
# app.config["config"] = app_config()
|
# app.config["config"] = app_config()
|
||||||
|
|
||||||
|
|
||||||
# logging
|
# logging
|
||||||
handler = RotatingFileHandler('app.log', maxBytes=10000, backupCount=3)
|
handler = RotatingFileHandler('app.log', maxBytes=10000, backupCount=3)
|
||||||
handler.setLevel(logging.DEBUG)
|
handler.setLevel(logging.DEBUG)
|
||||||
@@ -96,6 +95,7 @@ def internal_server_error(error):
|
|||||||
return "Internal Server Error", 500
|
return "Internal Server Error", 500
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
"""
|
"""
|
||||||
csrf = CSRFProtect()
|
csrf = CSRFProtect()
|
||||||
cors = CORS()
|
cors = CORS()
|
||||||
|
|||||||
11
config.py
11
config.py
@@ -14,6 +14,7 @@ Configuration variables
|
|||||||
from lib import argument_validation as av
|
from lib import argument_validation as av
|
||||||
import os
|
import os
|
||||||
from dotenv import load_dotenv, find_dotenv
|
from dotenv import load_dotenv, find_dotenv
|
||||||
|
from flask import current_app
|
||||||
|
|
||||||
load_dotenv(find_dotenv())
|
load_dotenv(find_dotenv())
|
||||||
|
|
||||||
@@ -77,14 +78,18 @@ class ProductionConfig(Config):
|
|||||||
|
|
||||||
# Set the configuration class based on the environment
|
# Set the configuration class based on the environment
|
||||||
# You can change 'development' to 'production' when deploying
|
# You can change 'development' to 'production' when deploying
|
||||||
config_env = os.getenv('FLASK_ENV')
|
config_env = os.getenv('FLASK_ENV', "not found")
|
||||||
|
with open('app.log', 'a') as f:
|
||||||
|
f.write(f'config_env: {config_env}\n')
|
||||||
|
# current_app.logger.error(f'config_env: {config_env}')
|
||||||
if config_env == 'development':
|
if config_env == 'development':
|
||||||
app_config = DevelopmentConfig
|
app_config = DevelopmentConfig
|
||||||
elif config_env == 'production':
|
else: ##if config_env == 'production':
|
||||||
app_config = ProductionConfig
|
app_config = ProductionConfig
|
||||||
|
"""
|
||||||
else:
|
else:
|
||||||
raise ValueError("Invalid configuration environment")
|
raise ValueError("Invalid configuration environment")
|
||||||
|
"""
|
||||||
|
|
||||||
# environment variables
|
# environment variables
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user