There is a column in the database called external_image_url. This column contains the source url of an image from an external source. Random selection is made from the products in the database. The image source of the selected product in the external_image_url column is assigned to the product_image_url = None row.
Inside the Flask application
f‘<img src=’{product_image_url}‘ alt=’Product Image‘ style=’max-width: 100%; height: auto;‘>
’
I want to print the image to the screen with the line. However, the image gives an error and does not appear. When I look at the image source
http://127.0.0.1:5000/%3Cbr%3E%3Ca%20href=%22https://image.com/image.jpg
in the form of
What exactly is the error here and what is the solution?
def select_random_product(results):
selected_product = random.choice(results)
product_image_url = selected_product.external_image_url
if product_image_url:
product_image_url = unquote(product_image_url)
else:
product_image_url = None
return selected_product, product_image_url
product_image_url = None
The error here is exactly whyThe method I tried is as I mentioned above.