Update code in endpoints/afrogospel.post.py

This commit is contained in:
Backend IM Bot 2025-03-28 18:20:23 +00:00
parent c30f24c2fe
commit ef277e891a

View File

@ -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