Files
mtusi2026lab3-fork/scripts/init_env.py
T

16 lines
467 B
Python

import secrets
from pathlib import Path
path = Path(__file__).resolve().parents[1] / ".env"
if not path.exists():
with path.open("x", encoding="utf-8") as file:
file.write(
"POSTGRES_DB=messenger\n"
"POSTGRES_USER=messenger\n"
f"POSTGRES_PASSWORD={secrets.token_hex(24)}\n"
"SESSION_TTL_SECONDS=3600\n"
)
print("Created .env with a new local password.")
else:
print("Using existing .env.")