I am trying to display an image from a list of JPEG images into an HTML page. I tried to use the following code on flask :
from flask import Flask, render_template, request
from Daily_runs import func,func_2
import os
import glob
app = Flask(__name__)
@app.route('/')
def index():
return render_template('Input.html')
@app.route('/hello', methods=['POST'])
def hello():
path = request.form['path']
func(path)
func_2()
images = glob.glob(os.path.join(path,'*.jpg'))
image = os.path.abspath(images[0])
return render_template('Image.html', user_image = image)
HTML template code :
<!DOCTYPE html>
<html>
<head>
<title>Index</title>
</head>
<body>
<img src={{user_image)}} alt="User Image">
</body>
</html>
The images does not get displayed instead only the alt text is displayed. Tried various other methods listed in this forum but could not succeed. Can anyone help on this ?
Daily_runsscript.