issue #36 - env variables: .env works from anywhere on the system using absolute path fixed the issue

This commit is contained in:
SovereigntyIsNotFreedom 2025-03-25 09:16:08 +00:00
parent acad0af3a1
commit 5a7d14c16a
3 changed files with 32 additions and 18 deletions

View file

@ -5,12 +5,16 @@ import json
import random
import os
if os.path.exists('.env'):
load_dotenv(".env")
else:
load_dotenv(".env.sample")
script_abs_path = os.path.dirname(os.path.abspath(__file__))
env_path = os.path.join(script_abs_path+"/.env")
default_env_path = os.path.join(script_abs_path+"/.env.sample")
websocket_port = os.environ.get("WEBSOCKET_PORT")
if os.path.exists(env_path):
load_dotenv(dotenv_path=env_path)
else:
load_dotenv(dotenv_path=default_env_path)
websocket_port = os.getenv("WEBSOCKET_PORT")
def is_simplex_link_valid(simplex_link: str) -> bool: