diff --git a/LyricsPy/app.py b/LyricsPy/app.py index 4f9cc9f..0e775f9 100644 --- a/LyricsPy/app.py +++ b/LyricsPy/app.py @@ -61,6 +61,15 @@ def album(album_id): songs = Song.query.filter_by(album_id=album_id).all() return render_template('album.html', album=album, songs=songs) +@app.route('/search') +def search(): + query = request.args.get('query', '') + if query: + songs = Song.query.filter(Song.title.contains(query)).all() + else: + songs = [] + return render_template('search.html', query=query, songs=songs) + if __name__ == '__main__': with app.app_context(): db.create_all() diff --git a/LyricsPy/instance/songs.db b/LyricsPy/instance/songs.db index 1086279..3c8b9dd 100644 Binary files a/LyricsPy/instance/songs.db and b/LyricsPy/instance/songs.db differ diff --git a/LyricsPy/templates/base.html b/LyricsPy/templates/base.html index 70b8da2..d396d4b 100644 --- a/LyricsPy/templates/base.html +++ b/LyricsPy/templates/base.html @@ -12,6 +12,10 @@ Home Add Song Add Album +
No songs found matching your query.
+{% endif %} + +Back to Home +{% endblock %}