diff --git a/app/__init__.py b/app/__init__.py index 76686d5ce0d5810bd94dbe77b6eb717da19efae9..e91b63c196082e48173e43cabf1b349bfd3d3490 100644 --- a/app/__init__.py +++ b/app/__init__.py @@ -41,7 +41,7 @@ def create_app(config_class=Config): from app.api import bp as api_bp app.register_blueprint(api_bp, url_prefix='/api') - + if __name__ == "__main__": app.run(use_reloader=True) diff --git a/app/main/routes.py b/app/main/routes.py index c6235a13466e7678a6c27a4a27f3b42225963dc8..4932a5cbd9075210fa8b642d1a716030b2807d45 100644 --- a/app/main/routes.py +++ b/app/main/routes.py @@ -1,9 +1,16 @@ -from flask import render_template +from flask import render_template, send_from_directory from app.main import bp import datetime +import os @bp.route('/') def index(): date=datetime.datetime.now() tomorrow_object = date + datetime.timedelta(days=1) - return render_template('index.html', today = date.strftime('%Y-%m-%d'), tomorrow = tomorrow_object.strftime('%Y-%m-%d')) \ No newline at end of file + return render_template('index.html', today = date.strftime('%Y-%m-%d'), tomorrow = tomorrow_object.strftime('%Y-%m-%d')) + +@bp.route('/uploads/listing_images/<filename>') +def upload_file(filename): + + upload_folder = os.path.join(os.getcwd(), 'app/uploads') + return send_from_directory(upload_folder, f'listing_images/{filename}') \ No newline at end of file diff --git a/app/templates/bookings/listings.html b/app/templates/bookings/listings.html index 2c991bcb3b4dc51e5a8279a3b4d3e79cc55d6743..5754b158cdae94d2b2fe3dd8b18f2f68efdb5639 100644 --- a/app/templates/bookings/listings.html +++ b/app/templates/bookings/listings.html @@ -13,7 +13,8 @@ <li class="slide-visible"> <div class="card shadow h-100"> <div class="ratio ratio-16x9"> - <img src="../uploads/listing_images/{{ top_listing_images[listing.id] }}.jpg" class="card-img-top" loading="lazy" alt="..."> + <th>{{top_listing_images[listing.id]}}</th> + <img src="{{ url_for('main.upload_file', filename=top_listing_images[listing.id]) }}" class="card-img-top" loading="lazy" alt="Main Image"> </div> <div class="card-body p-3 p-xl-4"> <h3 class="card-title h5">{{listing.destination_location}}</h3> diff --git a/app/uploads/listing_images/1.jpg b/app/uploads/listing_images/1.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7efd61d2d445c696b4f4689a845e8274123d2656 Binary files /dev/null and b/app/uploads/listing_images/1.jpg differ