-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
40 lines (32 loc) · 1.01 KB
/
app.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
from fastapi import FastAPI
from fastapi.staticfiles import StaticFiles
from fastapi.templating import Jinja2Templates
from backend.projects.cls import Projects
from backend.projects.putils import update_projects
from fastapi.middleware.cors import CORSMiddleware
from routers import main, extra
import os
import asyncio
if os.name == 'nt':
asyncio.set_event_loop_policy(asyncio.WindowsProactorEventLoopPolicy())
projects = Projects()
main.projects = projects
extra.projects = projects
update_projects(projects)
projects.checking()
app = FastAPI()
# noinspection PyTypeChecker
app.add_middleware(
CORSMiddleware,
allow_origins=["*"],
allow_credentials=True,
allow_methods=["*"],
allow_headers=["*"],
)
templates = Jinja2Templates(directory="templates")
app.mount("/static", StaticFiles(directory="static"), name="static")
app.include_router(main.router)
app.include_router(extra.router)
if __name__ == "__main__":
import uvicorn
uvicorn.run(app, host="127.0.0.1", port=1707, log_level="debug")