Skip to content
Snippets Groups Projects
Commit 2220d46d authored by Ethan2.Clay@live.uwe.ac.uk's avatar Ethan2.Clay@live.uwe.ac.uk
Browse files

Finish images link-up, to move logic separately to make uploads folder re-usable across app

parent 18301881
Branches
No related tags found
No related merge requests found
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'))
@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
......@@ -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>
......
app/uploads/listing_images/1.jpg

15.4 KiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment