2020-12-20 01:36:36 +01:00
|
|
|
import uvicorn
|
|
|
|
from fastapi import FastAPI, APIRouter
|
2020-12-20 14:19:57 +01:00
|
|
|
from fastapi.middleware.cors import CORSMiddleware
|
2020-12-20 01:36:36 +01:00
|
|
|
|
|
|
|
from routers import accidents, bikepoints, dashboard
|
|
|
|
|
|
|
|
app = FastAPI(
|
|
|
|
title="London Bikestations Dashboard API",
|
|
|
|
docs_url="/api/docs",
|
2020-12-20 23:44:24 +01:00
|
|
|
redoc_url="/api/redoc",
|
|
|
|
openapi_url="/api/openapi.json"
|
2020-12-20 01:36:36 +01:00
|
|
|
)
|
|
|
|
|
2020-12-20 14:19:57 +01:00
|
|
|
origins = [
|
|
|
|
"http://it-schwarz.net",
|
|
|
|
"https://it-schwarz.net",
|
|
|
|
"http://localhost",
|
|
|
|
"http://localhost:4200",
|
|
|
|
]
|
|
|
|
|
|
|
|
app.add_middleware(
|
|
|
|
CORSMiddleware,
|
|
|
|
allow_origins=origins,
|
|
|
|
allow_credentials=True,
|
|
|
|
allow_methods=["*"],
|
|
|
|
allow_headers=["*"],
|
|
|
|
)
|
|
|
|
|
2020-12-20 01:36:36 +01:00
|
|
|
v1_router = APIRouter()
|
|
|
|
v1_router.include_router(accidents.router)
|
|
|
|
v1_router.include_router(bikepoints.router)
|
|
|
|
v1_router.include_router(dashboard.router)
|
|
|
|
|
|
|
|
app.include_router(v1_router, prefix="/api/latest")
|
|
|
|
|
|
|
|
|
|
|
|
if __name__ == "__main__":
|
|
|
|
uvicorn.run("api:app", host="0.0.0.0", port=8080, reload=True)
|