Update code in endpoints/afrogospel.post.py
This commit is contained in:
parent
ef277e891a
commit
2455c8280c
@ -1,22 +1,15 @@
|
|||||||
from fastapi import APIRouter, Depends, HTTPException, status
|
from fastapi import APIRouter, status
|
||||||
from sqlalchemy.orm import Session
|
from typing import Dict
|
||||||
from typing import List
|
import random
|
||||||
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 = APIRouter()
|
||||||
|
|
||||||
@router.post("/afrogospel", status_code=200, response_model=List[SongSchema])
|
@router.post("/afrogospel", status_code=status.HTTP_200_OK, response_model=Dict[str, str])
|
||||||
async def get_random_afrogospel(
|
async def get_random_month():
|
||||||
db: Session = Depends(get_db)
|
months = [
|
||||||
):
|
"January", "February", "March", "April",
|
||||||
"""Get random afrogospel songs"""
|
"May", "June", "July", "August",
|
||||||
songs = get_random_afrogospel_songs(db)
|
"September", "October", "November", "December"
|
||||||
if not songs:
|
]
|
||||||
raise HTTPException(
|
random_month = random.choice(months)
|
||||||
status_code=status.HTTP_404_NOT_FOUND,
|
return {"month": random_month}
|
||||||
detail="No afrogospel songs found"
|
|
||||||
)
|
|
||||||
return songs
|
|
Loading…
x
Reference in New Issue
Block a user