Update code in endpoints/afrogospel.post.py
This commit is contained in:
parent
c30f24c2fe
commit
ef277e891a
@ -0,0 +1,22 @@
|
|||||||
|
from fastapi import APIRouter, Depends, HTTPException, status
|
||||||
|
from sqlalchemy.orm import Session
|
||||||
|
from typing import List
|
||||||
|
from core.database import get_db
|
||||||
|
from models.song import Song
|
||||||
|
from schemas.song import SongSchema
|
||||||
|
from helpers.song_helpers import get_random_afrogospel_songs
|
||||||
|
|
||||||
|
router = APIRouter()
|
||||||
|
|
||||||
|
@router.post("/afrogospel", status_code=200, response_model=List[SongSchema])
|
||||||
|
async def get_random_afrogospel(
|
||||||
|
db: Session = Depends(get_db)
|
||||||
|
):
|
||||||
|
"""Get random afrogospel songs"""
|
||||||
|
songs = get_random_afrogospel_songs(db)
|
||||||
|
if not songs:
|
||||||
|
raise HTTPException(
|
||||||
|
status_code=status.HTTP_404_NOT_FOUND,
|
||||||
|
detail="No afrogospel songs found"
|
||||||
|
)
|
||||||
|
return songs
|
Loading…
x
Reference in New Issue
Block a user