Thanks for taking a look Glenn, the solution you proposed might be a bit to tricky for a newbie like me. I've reverted to trying to employ javascript (the idea is to have a hidden 'loading' gif on my start page and show it after a click of an 'execute' button and leave it displayed after the dynamically constructed html/results are ready). I've pasted below a simplified version where i'm just trying to call a javascript function which would hide the 'textarea' before I return the 'done' html (delay represents the long function I will be running to get the real html) . Clearly i'm missing something here because clicking the button does not seem to call my javascript function, all that happens is a15 sec wait followed by display of 'done' html - any idea what am I doing wrong ?
from flask import Flask, request
app = Flask(name)
app.config["DEBUG"] = True
if name == "main":
app.run(debug = True)
@app.route("/", methods=["GET", "POST"])
def home_page():
if request.method == "POST":
import time
time.sleep(15)
return "<html>done</html>"
return """
<html>
<head>
<script LANGUAGE="JavaScript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js">
function hide_text()
{var ele = document.getElementById("text1");
ele.style.display = "none";
}
</script>
</head>
<textarea id="text1" rows="15" cols="100" ></textarea>
<form method="post">
<p><button onclick="hide_text();" value="Run" >Run </button></p>
</form>
"""