From d616b87701bb085014bfa6f63a753bd6e218c893 Mon Sep 17 00:00:00 2001 From: knight Date: Wed, 5 Nov 2025 11:03:42 -0500 Subject: [PATCH] Add python-dotenv support for automatic .env loading MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Added python-dotenv to requirements.txt - Config now automatically loads .env file if present - Allows local development without manually exporting env vars - Gracefully falls back if python-dotenv not installed 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- config.py | 9 +++++++++ requirements.txt | 1 + 2 files changed, 10 insertions(+) diff --git a/config.py b/config.py index 9e7eb26..393470d 100644 --- a/config.py +++ b/config.py @@ -16,6 +16,15 @@ from dataclasses import dataclass from pathlib import Path from typing import Optional +# Load .env file if it exists +try: + from dotenv import load_dotenv + _env_path = Path(__file__).parent / ".env" + if _env_path.exists(): + load_dotenv(_env_path) +except ImportError: + pass # python-dotenv not installed + @dataclass(frozen=True) class ElasticSettings: diff --git a/requirements.txt b/requirements.txt index c8bcc37..b04a199 100644 --- a/requirements.txt +++ b/requirements.txt @@ -2,3 +2,4 @@ Flask>=2.3 elasticsearch>=7.0.0,<9.0.0 youtube-transcript-api>=0.6 google-api-python-client>=2.0.0 +python-dotenv>=0.19.0