mirror of
https://github.com/rzmk/learnhouse.git
synced 2025-12-19 04:19:25 +00:00
feat: add content folder
This commit is contained in:
parent
6d97aa2072
commit
80fbb0ba2f
4 changed files with 25 additions and 12 deletions
8
src/core/events/content.py
Normal file
8
src/core/events/content.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
import os
|
||||
|
||||
|
||||
async def check_content_directory():
|
||||
if not os.path.exists(f"content"):
|
||||
# create folder for activity
|
||||
print("Creating content directory...")
|
||||
os.makedirs(f"content")
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
from typing import Callable
|
||||
from fastapi import FastAPI
|
||||
from config.config import LearnHouseConfig, get_learnhouse_config
|
||||
from src.core.events.content import check_content_directory
|
||||
from src.core.events.database import close_database, connect_to_db
|
||||
from src.core.events.logs import create_logs_dir
|
||||
from src.core.events.sentry import init_sentry
|
||||
|
|
@ -10,7 +11,7 @@ def startup_app(app: FastAPI) -> Callable:
|
|||
async def start_app() -> None:
|
||||
# Get LearnHouse Config
|
||||
learnhouse_config: LearnHouseConfig = get_learnhouse_config()
|
||||
app.learnhouse_config = learnhouse_config # type: ignore
|
||||
app.learnhouse_config = learnhouse_config # type: ignore
|
||||
|
||||
# Init Sentry
|
||||
await init_sentry(app)
|
||||
|
|
@ -21,10 +22,14 @@ def startup_app(app: FastAPI) -> Callable:
|
|||
# Create logs directory
|
||||
await create_logs_dir()
|
||||
|
||||
# Create content directory
|
||||
await check_content_directory()
|
||||
|
||||
return start_app
|
||||
|
||||
|
||||
def shutdown_app(app: FastAPI) -> Callable:
|
||||
async def close_app() -> None:
|
||||
await close_database(app)
|
||||
|
||||
return close_app
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue