fix .env load
This commit is contained in:
1 parent
3ad833b4e7
commit
5d30dde316
3 files changed
+103
-21
No files matched your search
@@ -1,9 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
from __future__ import annotations
|
||||
|
||||
import os
|
||||
from pathlib import Path
|
||||
|
||||
from flask import Flask
|
||||
|
||||
from auth import is_admin
|
||||
@@ -14,21 +11,6 @@ from storage import ensure_data_file
|
||||
from utils import cents_to_dollars, safe_date_label
|
||||
|
||||
|
||||
def load_local_env(env_path: Path) -> None:
|
||||
if not env_path.exists():
|
||||
return
|
||||
|
||||
for raw_line in env_path.read_text(encoding="utf-8").splitlines():
|
||||
line = raw_line.strip()
|
||||
if not line or line.startswith("#") or "=" not in line:
|
||||
continue
|
||||
|
||||
key, value = line.split("=", 1)
|
||||
key = key.strip()
|
||||
value = value.strip().strip('"').strip("'")
|
||||
os.environ.setdefault(key, value)
|
||||
|
||||
|
||||
def create_app() -> Flask:
|
||||
app = Flask(__name__)
|
||||
app.config.from_object(Config)
|
||||
@@ -48,9 +30,6 @@ def create_app() -> Flask:
|
||||
return app
|
||||
|
||||
|
||||
_env_path = Path(__file__).resolve().parent / ".env"
|
||||
load_local_env(_env_path)
|
||||
|
||||
app = create_app()
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in new issue
Block a user