diff --git a/app/main.py b/app/main.py index f2121c0..d8acaa3 100644 --- a/app/main.py +++ b/app/main.py @@ -40,7 +40,7 @@ def get_srv(service_id: int, db: Session): @app.get("/api/v1/ping") -def pong(): +async def pong(): return {"ping": "pong!"} @app.get("/api/v1/service") @@ -52,14 +52,14 @@ async def create_service(service: schemas.ServiceCreate, db: Session = Depends(g return crud.create_service(db=db, service=service) @app.get("/api/v1/service/{service_id}", response_model=schemas.Service) -def read_user(service_id: int, db: Session = Depends(get_db)): +async def read_service(service_id: int, db: Session = Depends(get_db)): db_service = get_srv(service_id, db) if db_service is None: raise HTTPException(status_code=404, detail="User not found") return db_service @app.put("/api/v1/service/{service_id}") -async def update_user(service_id: int, service: schemas.ServiceUpdate, db: Session = Depends(get_db)): +async def update_service(service_id: int, service: schemas.ServiceUpdate, db: Session = Depends(get_db)): if ((service.name is None) and (service.owner_id is None) and (service.is_private is None) and (service.description is None) and (service.service_type is None) and (service.url is None) and (service.is_active is None)): raise HTTPException(status_code=400, detail="No data provided") db_service = get_srv(service_id, db) @@ -69,7 +69,7 @@ async def update_user(service_id: int, service: schemas.ServiceUpdate, db: Sessi return {"update":"success"} @app.delete("/api/v1/service/{service_id}") -async def del_user(service_id: int, db: Session = Depends(get_db)): +async def delete_service(service_id: int, db: Session = Depends(get_db)): db_service = get_srv(service_id, db) if db_service is None: raise HTTPException(status_code=422, detail="Unprocessable entity") @@ -90,7 +90,7 @@ async def read_users(skip: int = 0, limit: int = 100, db: Session = Depends(get_ return crud.get_users(db=db, skip=skip, limit=limit) @app.get("/api/v1/users/{user_id}", response_model=schemas.User) -def read_user(user_id: int, db: Session = Depends(get_db)): +async def read_user(user_id: int, db: Session = Depends(get_db)): db_user = get_usr(user_id, db) if db_user is None: raise HTTPException(status_code=404, detail="User not found") @@ -107,7 +107,7 @@ async def update_user(user_id: int, user: schemas.UserUpdate, db: Session = Depe return {"update":"success"} @app.delete("/api/v1/users/{user_id}") -async def del_user(user_id: int, db: Session = Depends(get_db)): +async def delete_user(user_id: int, db: Session = Depends(get_db)): db_user = read_usr(user_id, db) if db_user is None: raise HTTPException(status_code=422, detail="Unprocessable entity")