initial wip
This commit is contained in:
33
main.py
Normal file
33
main.py
Normal file
@@ -0,0 +1,33 @@
|
||||
import datetime
|
||||
from contextlib import asynccontextmanager
|
||||
|
||||
from fastapi import FastAPI
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from src.populate import populate
|
||||
import src.routers as routers
|
||||
|
||||
@asynccontextmanager
|
||||
async def lifespan(app: FastAPI):
|
||||
populate()
|
||||
yield
|
||||
|
||||
updated = datetime.datetime.now(tz=datetime.timezone.utc)
|
||||
|
||||
app = FastAPI(lifespan=lifespan)
|
||||
|
||||
app.add_middleware(
|
||||
CORSMiddleware,
|
||||
allow_origins=["*"],
|
||||
allow_credentials=True,
|
||||
allow_methods=["*"],
|
||||
allow_headers=["*"],
|
||||
)
|
||||
|
||||
app.include_router(routers.status)
|
||||
|
||||
#
|
||||
# @app.get("/info/updated", tags=["info"])
|
||||
# async def get_timestamp_of_last_update():
|
||||
# """Timestamp of last update (YYYY-MM-DD HH:MM:SS UTC)."""
|
||||
# return updated.strftime("%Y-%m-%d %H:%M:%S")
|
||||
Reference in New Issue
Block a user