Files
mtusi2026lab2/scripts/init_env.py
T
Polina_Zhirnova 256d8b9035
Skeleton contracts / contracts (pull_request) Canceled after 0s
merge done project from github
2026-11-13 10:56:52 +03:00

13 lines
500 B
Python

"""Create secrets locally, never overwrite an existing configuration."""
from pathlib import Path
import secrets
path = Path(__file__).resolve().parents[1] / '.env'
try:
with path.open('x') as f:
f.write('APP_PORT=8080\nSESSION_TTL_SECONDS=3600\nPOSTGRES_PASSWORD='+secrets.token_hex(24)+'\nCURSOR_SECRET='+secrets.token_hex(32)+'\n')
path.chmod(0o600)
print('Created .env (local secrets; do not commit)')
except FileExistsError:
print('.env already exists; left unchanged')