diff --git a/LyricsPy/servicios/instance/songs.db b/LyricsPy/servicios/instance/songs.db index 11ab1d8..dcef283 100644 Binary files a/LyricsPy/servicios/instance/songs.db and b/LyricsPy/servicios/instance/songs.db differ diff --git a/LyricsPy/servicios/instance/uploads/nebraska.jpg b/LyricsPy/servicios/instance/uploads/nebraska.jpg new file mode 100644 index 0000000..eebc1a5 Binary files /dev/null and b/LyricsPy/servicios/instance/uploads/nebraska.jpg differ diff --git a/LyricsPy/servicios/lyrics/static/uploads/theriver.jpg b/LyricsPy/servicios/instance/uploads/theriver.jpg similarity index 100% rename from LyricsPy/servicios/lyrics/static/uploads/theriver.jpg rename to LyricsPy/servicios/instance/uploads/theriver.jpg diff --git a/LyricsPy/servicios/lyrics/__init__.py b/LyricsPy/servicios/lyrics/__init__.py index 4016171..3914dea 100644 --- a/LyricsPy/servicios/lyrics/__init__.py +++ b/LyricsPy/servicios/lyrics/__init__.py @@ -1,5 +1,5 @@ import os -from flask import Flask +from flask import Flask, url_for from flask_sqlalchemy import SQLAlchemy @@ -11,7 +11,7 @@ def create_app(): app.config['SECRET_KEY'] = 'secret-key-goes-here' app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///songs.db' - app.config['UPLOAD_FOLDER'] = 'lyrics/static/uploads' + app.config['UPLOAD_FOLDER'] = os.path.join(app.instance_path, 'uploads') app.config['MAX_CONTENT_LENGTH'] = 16 * 1024 * 1024 # 16 MB máximo from .models import db @@ -29,6 +29,8 @@ def create_app(): print(f"Current Environment: {os.getenv('ENVIRONMENT')}") print(f"Using Database: {app.config.get('DATABASE')}") + print(f"Directorio de uploads: {app.config.get('UPLOAD_FOLDER')}") + print(f"instance: {app.instance_path}") return app diff --git a/LyricsPy/servicios/lyrics/paginas.py b/LyricsPy/servicios/lyrics/paginas.py index fe4b53f..16fb533 100644 --- a/LyricsPy/servicios/lyrics/paginas.py +++ b/LyricsPy/servicios/lyrics/paginas.py @@ -1,4 +1,4 @@ -from flask import Blueprint, render_template, request, redirect, url_for, current_app +from flask import Blueprint, render_template, request, redirect, url_for, current_app, send_from_directory from werkzeug.utils import secure_filename import os @@ -83,3 +83,7 @@ def search(): else: songs = [] return render_template('search.html', query=query, songs=songs) + +@bp.route('/uploads/') +def uploaded_file(filename): + return send_from_directory(current_app.config['UPLOAD_FOLDER'], filename) diff --git a/LyricsPy/servicios/lyrics/templates/album.html b/LyricsPy/servicios/lyrics/templates/album.html index cbaea58..21e4de3 100644 --- a/LyricsPy/servicios/lyrics/templates/album.html +++ b/LyricsPy/servicios/lyrics/templates/album.html @@ -5,7 +5,7 @@

Artista: {{ album.artist }}

Año: {{ album.year }}

{% if album.cover_image %} -

{{ album.name }}

+

{{ album.name }}

{% else %}

No hay imágen disponible

{% endif %} diff --git a/LyricsPy/servicios/lyrics/templates/index.html b/LyricsPy/servicios/lyrics/templates/index.html index 1413d26..1772184 100644 --- a/LyricsPy/servicios/lyrics/templates/index.html +++ b/LyricsPy/servicios/lyrics/templates/index.html @@ -51,7 +51,7 @@ {% if album.cover_image %} - {{ album.name }} + {{ album.name }} {% else %} Sin imágen {% endif %} @@ -69,18 +69,4 @@
Añadir nuevo álbum - {% endblock %}