From ef277e891a1862f83a649582cf54de426506c595 Mon Sep 17 00:00:00 2001 From: Backend IM Bot Date: Fri, 28 Mar 2025 18:20:23 +0000 Subject: [PATCH] Update code in endpoints/afrogospel.post.py --- endpoints/afrogospel.post.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/endpoints/afrogospel.post.py b/endpoints/afrogospel.post.py index e69de29..3b86ace 100644 --- a/endpoints/afrogospel.post.py +++ b/endpoints/afrogospel.post.py @@ -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 \ No newline at end of file