Browse Source

La lista de albumes ahora tiene enlaces para ver información del álbum

politica
Celestino Rey 1 year ago
parent
commit
0e67ca5584
4 changed files with 27 additions and 1 deletions
  1. +6
    -0
      LyricsPy/app.py
  2. BIN
      LyricsPy/instance/songs.db
  3. +18
    -0
      LyricsPy/templates/album.html
  4. +3
    -1
      LyricsPy/templates/index.html

+ 6
- 0
LyricsPy/app.py View File

@ -55,6 +55,12 @@ def add_album():
return render_template('add_album.html') return render_template('add_album.html')
@app.route('/album/<int:album_id>')
def album(album_id):
album = Album.query.get_or_404(album_id)
songs = Song.query.filter_by(album_id=album_id).all()
return render_template('album.html', album=album, songs=songs)
if __name__ == '__main__': if __name__ == '__main__':
with app.app_context(): with app.app_context():
db.create_all() db.create_all()


BIN
LyricsPy/instance/songs.db View File


+ 18
- 0
LyricsPy/templates/album.html View File

@ -0,0 +1,18 @@
{% extends 'base.html' %}
{% block content %}
<h2>{{ album.name }}</h2>
<p><strong>Artist:</strong> {{ album.artist }}</p>
<p><strong>Year:</strong> {{ album.year }}</p>
<h3>Songs in this Album</h3>
<ul>
{% for song in songs %}
<li>
<a href="{{ url_for('song', song_id=song.id) }}">{{ song.title }} by {{ song.author }}</a>
</li>
{% endfor %}
</ul>
<a href="{{ url_for('index') }}">Back to Home</a>
{% endblock %}

+ 3
- 1
LyricsPy/templates/index.html View File

@ -21,7 +21,9 @@
<h2>Albums</h2> <h2>Albums</h2>
<ul> <ul>
{% for album in albums %} {% for album in albums %}
<li>{{ album.name }} by {{ album.artist }} ({{ album.year }})</li>
<li>
<a href="{{ url_for('album', album_id=album.id) }}">{{ album.name }} by {{ album.artist }} ({{ album.year }})</a>
</li>
{% endfor %} {% endfor %}
</ul> </ul>
<hr> <hr>


Loading…
Cancel
Save