Update code in endpoints/signup.post.py

This commit is contained in:
Backend IM Bot 2025-03-21 10:23:07 +00:00
parent 995f6fb8b2
commit 57302dd832

View File

@ -1,32 +1,30 @@
from fastapi import APIRouter, HTTPException from fastapi import APIRouter, HTTPException
playlists = [ customers = [] # In-memory storage
{
"id": "playlist1",
"songs": [
{"id": "song1", "title": "Song One", "artist": "Artist A"},
{"id": "song2", "title": "Song Two", "artist": "Artist B"}
]
}
]
router = APIRouter() router = APIRouter()
@router.post("/playlist/songs") @router.post("/signup")
async def get_playlist_songs( async def list_customers(
playlist_id: str = "playlist1" store_id: str = "default_store",
page: int = 1,
limit: int = 10
): ):
"""Get songs from a playlist""" """Get list of store customers"""
playlist = next((p for p in playlists if p["id"] == playlist_id), None) if not any(c["store_id"] == store_id for c in customers):
if not playlist: raise HTTPException(status_code=400, detail="Store not found")
raise HTTPException(status_code=400, detail="Playlist not found")
store_customers = [c for c in customers if c["store_id"] == store_id]
start = (page - 1) * limit
end = start + limit
return { return {
"message": "Songs retrieved successfully", "message": "Customers retrieved successfully",
"playlist_id": playlist_id, "store_id": store_id,
"songs": playlist["songs"], "customers": store_customers[start:end],
"features": { "pagination": {
"total_songs": len(playlist["songs"]), "page": page,
"can_shuffle": True "total": len(store_customers),
"pages": (len(store_customers) + limit - 1) // limit
} }
} }