13 lines
500 B
Python
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')
|