Update code in endpoints/signup.post.py

This commit is contained in:
Backend IM Bot 2025-03-21 11:34:53 +00:00
parent 57302dd832
commit 5e12c5a0e5

View File

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