Answer the question
In order to leave comments, you need to log in
How to add a preloader for a site?
The site has such functionality (implemented on flask) - a file is applauded through a form, then this file is processed for quite a long time, up to a minute. After processing is complete, a redirect to a new page with the output of the result occurs. I need some kind of js stub at the time of processing. I copied and pasted in the front at the level. I found a couple of options for ready-made scripts, but they only work at the time of the initial load of the page with the form. How to make the script run at the right time? I suppose that you need to dance from the server response 200, but I don’t know which side to take. And how to set the start time of the script is the same mystery.
@app.route("/done/<count>")
def result(count=0):
count = count
return render_template('result.html', count=count)
@app.route('/', methods=['GET', 'POST'])
def index():
if request.method == 'POST':
........
#Upload and save img file logic
......
img = (os.path.join(app.config['UPLOAD_FOLDER'], filename))
detection, count = performDetect(imagePath = img)#эта фунция обрабатывает файл и возвращает detection и count , в момент выполнения нужна заглушка
#Спустя время затраченное на выполнение performDetect происходит редирект
return redirect(url_for("result", count=count))
return render_template("index.html")
Answer the question
In order to leave comments, you need to log in
while uploading a file, just put a gif image of a file upload like this
and the response will still be a redirect
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question