Whitelist-API/API/api/__main__.py
2023-10-24 01:37:34 -05:00

19 lines
426 B
Python

from litestar.response.redirect import Redirect
import uvicorn
from litestar import Litestar, get
@get("/")
async def index() -> Redirect:
return Redirect("/schema/swagger")
@get("/books/{book_id:int}")
async def get_book(book_id: int) -> dict[str, int]:
return {"book_id": book_id}
if __name__ == "__main__":
app = Litestar([index, get_book])
uvicorn.run(__name__ + ":app", port=5000, log_level="info")