mirror of
https://github.com/kevinveenbirkenbach/homepage.veen.world.git
synced 2025-07-07 03:25:12 +02:00
Added correct env path import
This commit is contained in:
parent
dfbc840c69
commit
35bfeeb51e
14
main.py
14
main.py
@ -22,6 +22,16 @@ import argparse
|
|||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import os
|
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))
|
PORT = int(os.getenv("PORT", 5000))
|
||||||
|
|
||||||
def run_command(command, dry_run=False):
|
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.
|
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)
|
run_command(command, args.dry_run)
|
||||||
|
|
||||||
|
|
||||||
@ -223,7 +233,7 @@ def main():
|
|||||||
|
|
||||||
# Browse command
|
# Browse command
|
||||||
parser_browse = subparsers.add_parser(
|
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)
|
parser_browse.set_defaults(func=browse)
|
||||||
|
|
||||||
|
1
requirements.txt
Normal file
1
requirements.txt
Normal file
@ -0,0 +1 @@
|
|||||||
|
python-dotenv
|
Loading…
x
Reference in New Issue
Block a user