how to create ajax api in flask
from flask import *
app = Flask(__name__)
@app.route("/", methods=["POST", "GET"])
def home():
return render_template("index.html")
# This function gets param1 from url yourflaskroot/getdata
# which was the url set in ajax code and return param1 back to it
# you can write a simple ajax code to test it out
@app.route("/getdata")
def myFunction():
# Fill parameter with the argument sent from ajax
parameter = request.args.get('param1')
# Send parameter as an argument to ajax
return f"the returned data from python is : {parameter}"
if __name__ == "__main__":
app.run(debug=True)<script type=text/javascript src="{{
url_for('static', filename='jquery.js') }}"></script>
Also in JavaScript:
- angular back button
- title case javascript
- javascript iterate through a binary tree
- angry professor javascript
- append data array javascript
- jquery click hold down
- javascript save table as excel
- jquery make new variable with dynamic name
- javascript page load event
- connect react native app to local api macos
- prime factorization javascript
- manipulação de array javascript
- .map function
- express get request origin
- get dirname to last directory node
- django jquery
- jquery get left position
- loopback model find by id
- redux saga fetch json
- import all from javascript
- return the value of a selected option in a drop-down list
- angularjs switch
- bajar archivos node
- debug.xcconfig: unable to open file react native