From 353093809f415facf06f2cd45e6254b092868e46 Mon Sep 17 00:00:00 2001 From: Peter Stockings Date: Sun, 7 Apr 2024 22:30:28 +1000 Subject: [PATCH] Load local .env file in dev mode (Will make same change to other projects) --- app.py | 6 ++++++ requirements.txt | 3 ++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/app.py b/app.py index bdc14f8..cec353f 100644 --- a/app.py +++ b/app.py @@ -11,6 +11,12 @@ from utils import count_prs_over_time, get_date_info, get_people_and_exercise_re from flask_htmx import HTMX import minify_html from urllib.parse import quote +import os +from dotenv import load_dotenv + +# Load environment variables from .env file in non-production environments +if os.environ.get('FLASK_ENV') != 'production': + load_dotenv() app = Flask(__name__) app.config.from_pyfile('config.py') diff --git a/requirements.txt b/requirements.txt index 2b67ad7..d336f5c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -9,4 +9,5 @@ minify-html==0.10.3 jinja2-fragments==0.3.0 Werkzeug==2.2.2 numpy==1.19.5 -pandas==1.3.1 \ No newline at end of file +pandas==1.3.1 +python-dotenv==1.0.1 \ No newline at end of file