ЛР 3 — БВТ-2302 — Сабитов — на 3

This commit is contained in:
2026-12-01 18:09:13 +03:00
parent 0ab3a341aa
commit d79bf5c481
36 changed files with 1944 additions and 36 deletions
+14
View File
@@ -0,0 +1,14 @@
"""Create local credentials once. Never print or overwrite an existing secret."""
from pathlib import Path
import secrets
root = Path(__file__).resolve().parents[1]
path = root / '.env'
if path.exists():
print('Existing .env retained')
else:
settings = (root / '.env.example').read_text(encoding='utf-8')
settings = settings.replace('POSTGRES_PASSWORD=', 'POSTGRES_PASSWORD=' + secrets.token_hex(24))
with path.open('x', encoding='utf-8', newline='\n') as output:
output.write(settings)
print('Created local .env with a random password; keep it outside Git')