Update code in endpoints/api/v1/endpoint.post.py
This commit is contained in:
parent
d36c8ebe37
commit
dd0e5da19e
@ -1,44 +1,26 @@
|
|||||||
from fastapi import APIRouter, Depends, HTTPException
|
from fastapi import APIRouter, Depends, HTTPException
|
||||||
from core.database import fake_users_db
|
from core.database import fake_users_db
|
||||||
from typing import List, Optional
|
from core.auth import get_current_user_dummy
|
||||||
|
|
||||||
router = APIRouter()
|
router = APIRouter()
|
||||||
|
|
||||||
@router.post("/api/v1/endpoint")
|
@router.post("/logout")
|
||||||
async def get_playlist_songs(
|
async def logout_demo(
|
||||||
playlist_id: str,
|
current_user = Depends(get_current_user_dummy)
|
||||||
limit: Optional[int] = 50,
|
|
||||||
offset: Optional[int] = 0
|
|
||||||
):
|
):
|
||||||
"""Fetch songs from a playlist"""
|
"""Demo logout endpoint"""
|
||||||
if not playlist_id:
|
if not current_user:
|
||||||
raise HTTPException(status_code=400, detail="Playlist ID is required")
|
raise HTTPException(status_code=401, detail="Not authenticated")
|
||||||
|
|
||||||
# Demo playlist data structure
|
|
||||||
fake_playlists_db = {
|
|
||||||
"playlist1": [
|
|
||||||
{"id": "1", "title": "Song 1", "artist": "Artist 1", "duration": "3:45"},
|
|
||||||
{"id": "2", "title": "Song 2", "artist": "Artist 2", "duration": "4:20"},
|
|
||||||
{"id": "3", "title": "Song 3", "artist": "Artist 3", "duration": "3:15"}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
|
|
||||||
playlist = fake_playlists_db.get(playlist_id)
|
|
||||||
if not playlist:
|
|
||||||
raise HTTPException(status_code=404, detail="Playlist not found")
|
|
||||||
|
|
||||||
paginated_songs = playlist[offset:offset + limit]
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"message": "Songs fetched successfully",
|
"message": "Logout successful",
|
||||||
"data": {
|
"username": current_user,
|
||||||
"playlist_id": playlist_id,
|
|
||||||
"songs": paginated_songs,
|
|
||||||
"total_songs": len(playlist)
|
|
||||||
},
|
|
||||||
"metadata": {
|
"metadata": {
|
||||||
"limit": limit,
|
"session_ended": True,
|
||||||
"offset": offset,
|
"timestamp": "demo_timestamp"
|
||||||
"has_more": (offset + limit) < len(playlist)
|
},
|
||||||
}
|
"next_steps": [
|
||||||
|
"Clear local storage",
|
||||||
|
"Redirect to login page"
|
||||||
|
]
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user