22 lines
704 B
Python
22 lines
704 B
Python
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 |