forked from sylvoslee/timeflow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
46 lines (31 loc) · 1.3 KB
/
main.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
45
46
import os
from pathlib import Path
from os import path
from fastapi.staticfiles import StaticFiles
from starlette.middleware.sessions import SessionMiddleware
from idom.backend import fastapi
from idom.backend.starlette import Options
# Appflow Views
from appflow.views.index import router as index_router
from appflow.views.site import router as site_router
from appflow.views.timeflow import router as timeflow_router
from appflow.views.login_github import SESSION_SECRET_KEY, router as gh_login_router
# Applications
from applications.site.index import site_index
from applications.timeflow.index import timeflow
SESSION_SECRET_KEY = os.getenv("SESSION_SECRET_KEY")
# Create the fastapi app
app = fastapi.create_development_app()
# Specify location of static files and specify middleware
HERE = Path(__file__).parent
STATIC_PATH = path.join("appflow", "static")
app.mount("/static", StaticFiles(directory=str(STATIC_PATH)), name="static")
app.add_middleware(SessionMiddleware, secret_key=str(SESSION_SECRET_KEY))
# IDOM Applications
fastapi.configure(app, site_index, Options(url_prefix="/_site"))
fastapi.configure(app, timeflow, Options(url_prefix="/_timeflow"))
app.include_router(site_router)
app.include_router(timeflow_router)
# FastAPI Views
app.include_router(gh_login_router)
app.include_router(index_router)