I am new to flask and I start to learn post and get requests. I do them with a form.
FLASK
from flask import Flask,render_template,request
app = Flask(__name__)
@app.route("/a",methods=['POST','GET'])
def home():
if request.method == 'POST':
a = request.form['name']
print(a)
return render_template('index.html',b=a)
if __name__ == '__main__':
app.run(debug=True)
HTML
<!DOCTYPE html>
<html>
<body>
<form action="" method='post'>
<input type='text' name='name'>
<button>OK</button>
</form>
<p>{{b}}</p>
</body>
</html>
How can I send data like this but without a form?
When I run it I get "POST /a HTTP/1.1" 200 -
Thanks.