I have run into a problem with my javascript/python script. What I am trying to do is pass a string to python flask so I can use it later. When I click the button to send the string, there are no errors but nothing happens. I am basically a self taught coder so I apologise if my script it not properly formatted!
Javascript:
$('#button').click(function() {
$.ajax({
url:"/",
type: 'POST',
data: data,
...
Python Flask:
from flask import Flask
from flask import request
from flask import render_template
app = Flask(__name__)
@app.route('/', methods=['POST', 'GET'])
def home():
if request.method == "POST":
string = request.args.get(data)
print(string)
return render_template('index.html')
if __name__ == '__main__':
app.run(debug=True)
I want to be able to see the string printed to either the console or the command prompt, I assume print() is the right way to do this? Any help would be welcome, thank you :)