Step-1 crate a structure like this

Step-2 ) create an index.html in templates
<html>
<head>
<title>Webphplearn.com</title>
</head>
<body>
<form action = "/imageupload" method = "post" enctype="multipart/form-data">
<input type="file" name="file" />
<input type = "submit" value="Upload">
</form>
</body>
</html>
Step 3) Add two route and function in api
from flask import Flask, request, jsonify,render_template, redirect, url_for
from fileinput import filename
@app.route('/')
def main():
return render_template("index.html")
@app.route('/imageupload', methods = ['POST'])
def success():
if request.method == 'POST':
f = request.files['file']
f.save(f.filename)
return render_template("imageupload.html", name = f.filename)
Step -3) create imageupload.html file in templates folder
<html>
<head>
<title>Image upload</title>
</head>
<body>
<p> File uploaded successfully</p>
</body>
</html>

Final output
