diff --git a/run_web.sh b/run_web.sh index 3e06c4a..adfe45d 100755 --- a/run_web.sh +++ b/run_web.sh @@ -4,4 +4,5 @@ export PROJECT_ROOT=$( cd "$(dirname "$0")" ; pwd -P ) source "$PROJECT_ROOT/venv/bin/activate" export PYTHONPATH="$PROJECT_ROOT/src" export NATURE_RECORDER_DB="$PROJECT_ROOT/data/naturerecorder.db" +export FLASK_ENV=development python -m naturerec_web diff --git a/src/naturerec_web/__init__.py b/src/naturerec_web/__init__.py index e82c912..fe34a6e 100644 --- a/src/naturerec_web/__init__.py +++ b/src/naturerec_web/__init__.py @@ -28,8 +28,6 @@ def create_app(environment="production"): config_object = f"naturerec_web.config.{'ProductionConfig' if environment == 'production' else 'DevelopmentConfig'}" app.config.from_object(config_object) - print(config_object) - print(os.environ["SECRET_KEY"]) # Register the blueprints app.secret_key = os.environ["SECRET_KEY"] diff --git a/src/naturerec_web/__main__.py b/src/naturerec_web/__main__.py index 5d9c456..4159d46 100644 --- a/src/naturerec_web/__main__.py +++ b/src/naturerec_web/__main__.py @@ -2,4 +2,7 @@ from naturerec_web import create_app environment = sys.argv[1] if len(sys.argv) > 1 else "development" -create_app(environment).run() +if environment == "development": + create_app(environment).run(debug=True, use_reloader=True) +else: + create_app(environment).run(host="0.0.0.0") diff --git a/src/naturerec_web/config.py b/src/naturerec_web/config.py index ce34ffd..61edaa4 100644 --- a/src/naturerec_web/config.py +++ b/src/naturerec_web/config.py @@ -6,7 +6,10 @@ from dotenv import load_dotenv basedir = os.path.dirname(os.path.dirname(os.path.dirname(__file__))) -env_file = os.path.join(basedir, "data", ".env") +if "NATURE_RECORDER_DATA_FOLDER" in os.environ: + env_file = os.path.join(os.environ["NATURE_RECORDER_DATA_FOLDER"], ".env") +else: + env_file = os.path.join(basedir, "data", ".env") load_dotenv(env_file) @@ -15,14 +18,8 @@ class BaseConfig: class ProductionConfig(BaseConfig): - FLASK_ENV = 'production' - DEBUG = False TESTING = False - SERVER_NAME = "0.0.0.0" class DevelopmentConfig(BaseConfig): - FLASK_ENV = 'development' - DEBUG = True TESTING = True - SERVER_NAME = "127.0.0.1:5000"