1from flask import *
2
3app = Flask(__name__)
4
5@app.route("/", methods=["POST", "GET"])
6def home():
7 return render_template("index.html")
8
9# This function gets param1 from url yourflaskroot/getdata
10# which was the url set in ajax code and return param1 back to it
11# you can write a simple ajax code to test it out
12@app.route("/getdata")
13def myFunction():
14 # Fill parameter with the argument sent from ajax
15 parameter = request.args.get('param1')
16 # Send parameter as an argument to ajax
17 return f"the returned data from python is : {parameter}"
18
19
20if __name__ == "__main__":
21 app.run(debug=True)