Update code in endpoints/afrogospel.post.py

This commit is contained in:
Backend IM Bot 2025-03-29 21:15:18 +00:00
parent ef277e891a
commit 2455c8280c

View File

@ -1,22 +1,15 @@
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
from fastapi import APIRouter, status
from typing import Dict
import random
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
@router.post("/afrogospel", status_code=status.HTTP_200_OK, response_model=Dict[str, str])
async def get_random_month():
months = [
"January", "February", "March", "April",
"May", "June", "July", "August",
"September", "October", "November", "December"
]
random_month = random.choice(months)
return {"month": random_month}