from typing import List, Type from fastapi import FastAPI from fastapi.staticfiles import StaticFiles from starlette.middleware.sessions import SessionMiddleware from starlette_wtf import CSRFProtectMiddleware from . import common from .sql import db # Add your paths here from .paths.paths import Paths from .paths import pages from .paths import table from .paths import errors paths: List[Type[Paths]] = [ pages.MainPaths, table.TablePaths, errors.ErrorsPaths, ] db.Base.metadata.create_all(bind=db.engine) app = FastAPI() app.mount( '/static', StaticFiles(directory=common.static_dir), name='static', ) for p in paths: p(app).add_paths() app.add_middleware( SessionMiddleware, secret_key=common.settings.session_key, ) app.add_middleware( CSRFProtectMiddleware, csrf_secret=common.settings.csrf_key, )