Files
vpsx-db/main.py

34 lines
765 B
Python
Raw Permalink Normal View History

2025-08-28 16:01:44 +00:00
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")