INNER CODE UNIT · Python

create_cast

paurakhsharma/python-microservice-fastapi · cast-service/app/api/casts.py:10

async def create_cast(payload: CastIn):
    cast_id = await db_manager.add_cast(payload)

    response = {
        'id': cast_id,
        **payload.dict()
    }

    return response

@casts.get('/{id}/', response_model=CastOut)
async def get_cast(id: int):
    cast = await db_manager.get_cast(id)
    if not cast:
        raise HTTPException(status_code=404, detail="Cast not found")
    return cast

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…