From 35bfeeb51ea19351b383193f266eef61f0902c12 Mon Sep 17 00:00:00 2001 From: Kevin Veen-Birkenbach Date: Sat, 5 Jul 2025 10:12:49 +0200 Subject: [PATCH] Added correct env path import --- main.py | 14 ++++++++++++-- requirements.txt | 1 + 2 files changed, 13 insertions(+), 2 deletions(-) create mode 100644 requirements.txt diff --git a/main.py b/main.py index c839547..de868ad 100755 --- a/main.py +++ b/main.py @@ -22,6 +22,16 @@ import argparse import subprocess import sys import os +from dotenv import load_dotenv +from pathlib import Path + +# Always load .env from the script's directory +dotenv_path = Path(__file__).resolve().parent / ".env" + +if dotenv_path.exists(): + load_dotenv(dotenv_path) +else: + print(f"⚠️ Warning: No .env file found at {dotenv_path}") PORT = int(os.getenv("PORT", 5000)) def run_command(command, dry_run=False): @@ -195,7 +205,7 @@ def browse(args): This command launches the Chromium browser to view the running application. """ - command = ["chromium", "http://localhost:5000"] + command = ["chromium", f"http://localhost:{PORT}"] run_command(command, args.dry_run) @@ -223,7 +233,7 @@ def main(): # Browse command parser_browse = subparsers.add_parser( - "browse", help="Open http://localhost:5000 in Chromium browser." + "browse", help="Open application in Chromium browser." ) parser_browse.set_defaults(func=browse) diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..3e338bf --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +python-dotenv \ No newline at end of file