init
This commit is contained in:
commit
4be274d9e2
39 changed files with 2548 additions and 0 deletions
31
learn_sql_model/api/hero.py
Normal file
31
learn_sql_model/api/hero.py
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
from typing import Annotated
|
||||
|
||||
from fastapi import APIRouter, Depends
|
||||
|
||||
from learn_sql_model.api.user import oauth2_scheme
|
||||
from learn_sql_model.models import Hero
|
||||
|
||||
hero_router = APIRouter()
|
||||
|
||||
|
||||
@hero_router.get("/items/")
|
||||
async def read_items(token: Annotated[str, Depends(oauth2_scheme)]):
|
||||
return {"token": token}
|
||||
|
||||
|
||||
@hero_router.get("/hero/{id}")
|
||||
def get_hero(id: int) -> Hero:
|
||||
"get one hero"
|
||||
return Hero.get(item_id=id)
|
||||
|
||||
|
||||
@hero_router.post("/hero/")
|
||||
def post_hero(hero: Hero) -> Hero:
|
||||
"read all the heros"
|
||||
return hero.post()
|
||||
|
||||
|
||||
@hero_router.get("/heros/")
|
||||
def get_heros() -> list[Hero]:
|
||||
"get all heros"
|
||||
return Hero.get()
|
||||
Loading…
Add table
Add a link
Reference in a new issue