-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathdependencies.py
More file actions
40 lines (31 loc) · 1.2 KB
/
dependencies.py
File metadata and controls
40 lines (31 loc) · 1.2 KB
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
import os
from functools import lru_cache
from fastapi.templating import Jinja2Templates
from sqlalchemy.orm import Session
from app import config
from app.database import SessionLocal
from app.internal.logger_customizer import LoggerCustomizer
GOOGLE_ERROR = config.CLIENT_SECRET_FILE is None
APP_PATH = os.path.dirname(os.path.realpath(__file__))
MEDIA_PATH = os.path.join(APP_PATH, config.MEDIA_DIRECTORY)
STATIC_PATH = os.path.join(APP_PATH, "static")
TEMPLATES_PATH = os.path.join(APP_PATH, "templates")
CURSORS_PATH = os.path.join(APP_PATH, "media/cursors/")
templates = Jinja2Templates(directory=TEMPLATES_PATH)
templates.env.add_extension('jinja2.ext.i18n')
# Configure logger
logger = LoggerCustomizer.make_logger(config.LOG_PATH,
config.LOG_FILENAME,
config.LOG_LEVEL,
config.LOG_ROTATION_INTERVAL,
config.LOG_RETENTION_INTERVAL,
config.LOG_FORMAT)
def get_db() -> Session:
db = SessionLocal()
try:
yield db
finally:
db.close()
@lru_cache()
def get_settings():
return config.Settings()