50 lines
1.4 KiB
Python
50 lines
1.4 KiB
Python
from __future__ import annotations
|
|
|
|
from os import environ
|
|
|
|
from dotenv import load_dotenv
|
|
|
|
|
|
load_dotenv()
|
|
|
|
|
|
class Config:
|
|
SECRET_KEY = environ.get("SECRET_KEY")
|
|
SECURITY_PASSWORD_SALT = environ.get("SECURITY_PASSWORD_SALT")
|
|
DB_USER = environ.get("DB_USER")
|
|
DB_PASSWORD = environ.get("DB_PASSWORD")
|
|
DB_HOST = environ.get("DB_HOST")
|
|
DB_PORT = environ.get("DB_PORT")
|
|
DB_NAME = environ.get("DB_NAME")
|
|
SECURITY_REGISTERABLE = True
|
|
GOOGLE_CLIENT_ID = environ.get("GOOGLE_CLIENT_ID")
|
|
GOOGLE_CLIENT_SECRET = environ.get("GOOGLE_CLIENT_SECRET")
|
|
|
|
|
|
class Production(Config):
|
|
FLASK_ENV = "production"
|
|
DEBUG = False
|
|
DB_SOCKET_DIR = environ.get("DB_SOCKET_DIR", "/cloudsql")
|
|
CLOUD_SQL_CONNECTION_NAME = environ.get("CLOUD_SQL_CONNECTION_NAME")
|
|
DB_URL = f"postgresql+psycopg://{Config.DB_USER}:{Config.DB_PASSWORD}@{Config.DB_HOST}:{Config.DB_PORT}/{Config.DB_NAME}?host={DB_SOCKET_DIR}/{CLOUD_SQL_CONNECTION_NAME}" # noqa: E501
|
|
|
|
|
|
class Development(Config):
|
|
FLASK_ENV = "development"
|
|
DEBUG = True
|
|
TESTING = True
|
|
DB_USER = "postgres"
|
|
DB_PASSWORD = "hello"
|
|
DB_HOST = "localhost"
|
|
DB_NAME = "postgres"
|
|
DB_PORT = "5432"
|
|
DB_URL = f"postgresql+psycopg://{DB_USER}:{DB_PASSWORD}@{DB_HOST}:{DB_PORT}/{DB_NAME}"
|
|
|
|
|
|
class Testing(Config):
|
|
FLASK_ENV = "testing"
|
|
DEBUG = True
|
|
TESTING = True
|
|
WTF_CSRF_ENABLED = False
|
|
DB_URL = "sqlite:///test.db"
|