-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.py
44 lines (29 loc) · 952 Bytes
/
config.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
import os
from pathlib import Path
from dotenv import load_dotenv
env_path = Path(".") / ".env"
load_dotenv(dotenv_path=env_path)
BASEDIR = os.path.abspath(os.path.dirname(__file__))
def create_sqlite_uri(database):
return f"sqlite:///{os.path.join(BASEDIR, database)}"
class Config:
SECRET_KEY = os.getenv("SECRET_KEY")
SQLALCHEMY_RECORD_QUERIES = True
SQLALCHEMY_TRACK_MODIFICATIONS = False
@staticmethod
def init_app(app):
pass
class DevelopmentConfig(Config):
DEBUG = True
SQLALCHEMY_DATABASE_URI = create_sqlite_uri("development.db")
class TestingConfig(Config):
TESTING = True
SQLALCHEMY_DATABASE_URI = create_sqlite_uri("testing.db")
class ProductionConfig(Config):
SQLALCHEMY_DATABASE_URI = create_sqlite_uri("production.db")
config = {
"development": DevelopmentConfig,
"testing": TestingConfig,
"production": ProductionConfig,
"default": DevelopmentConfig,
}