przebudowa systemu
This commit is contained in:
45
config.py
Normal file
45
config.py
Normal file
@@ -0,0 +1,45 @@
|
||||
import os
|
||||
|
||||
def _get_bool(name: str, default: bool) -> bool:
|
||||
val = os.environ.get(name)
|
||||
if val is None:
|
||||
return default
|
||||
return str(val).strip().lower() in {"1", "true", "t", "yes", "y", "on"}
|
||||
|
||||
def _get_str(name: str, default: str) -> str:
|
||||
return os.environ.get(name, default)
|
||||
|
||||
class Config:
|
||||
"""
|
||||
Konfiguracja aplikacji pobierana z ENV (z sensownymi domyślnymi wartościami).
|
||||
Zmiennych szukamy pod nazwami:
|
||||
- DATABASE_URL
|
||||
- SECRET_KEY
|
||||
- ALLOW_REGISTRATION
|
||||
- MAIN_ADMIN_USERNAME
|
||||
- MAIN_ADMIN_PASSWORD
|
||||
- BLOCK_BOTS
|
||||
- CACHE_CONTROL_HEADER
|
||||
- PRAGMA_HEADER
|
||||
- ROBOTS_TAG
|
||||
"""
|
||||
|
||||
# Baza danych
|
||||
SQLALCHEMY_DATABASE_URI = _get_str("DATABASE_URL", "sqlite:///baza.db")
|
||||
|
||||
# Flask
|
||||
SECRET_KEY = _get_str("SECRET_KEY", "tajny_klucz")
|
||||
|
||||
# Rejestracja i konto admina
|
||||
ALLOW_REGISTRATION = _get_bool("ALLOW_REGISTRATION", False)
|
||||
MAIN_ADMIN_USERNAME = _get_str("MAIN_ADMIN_USERNAME", "admin")
|
||||
MAIN_ADMIN_PASSWORD = _get_str("MAIN_ADMIN_PASSWORD", "admin")
|
||||
|
||||
# Indeksowanie / cache / robots
|
||||
BLOCK_BOTS = _get_bool("BLOCK_BOTS", True)
|
||||
CACHE_CONTROL_HEADER = _get_str("CACHE_CONTROL_HEADER", "max-age=600")
|
||||
PRAGMA_HEADER = _get_str("PRAGMA_HEADER", "")
|
||||
ROBOTS_TAG = _get_str("ROBOTS_TAG", "noindex, nofollow, nosnippet, noarchive")
|
||||
|
||||
# (opcjonalnie) wyłącz warningi track_modifications
|
||||
SQLALCHEMY_TRACK_MODIFICATIONS = False
|
Reference in New Issue
Block a user