Skip to content

Commit

Permalink
routes added
Browse files Browse the repository at this point in the history
  • Loading branch information
harikris001 committed Aug 31, 2024
1 parent eca71e0 commit 905bb4e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions server/routes/song.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
from models.song import Song
from database import get_db
from pydantics_schema.favourite_song import FavouriteSong

router = APIRouter()

@router.post('/upload',status_code=201)
Expand Down Expand Up @@ -76,4 +75,10 @@ def favourite_song(song: FavouriteSong, db: Session = Depends(get_db), auth_dict
def list_fav_songs(db: Session = Depends(get_db), auth_dict = Depends(auth_middleware)):
user_id = auth_dict['uid']
fav_songs = db.query(Favourite).filter(Favourite.user_id == user_id).options(joinedload(Favourite.song), ).all()
return fav_songs
return fav_songs


@router.get('/search/',status_code=200)
def search_songs(query: str, db: Session = Depends(get_db),auth_dict = Depends(auth_middleware)):
songs = db.query(Song).filter(Song.song_name.ilike(f'%{query}%')).limit(10).all()
return songs

0 comments on commit 905bb4e

Please sign in to comment.