I have a HTML form inside a landing page and I want to send the forms data by ajax to /data rout.
The problem is validating this HTML form in backend.
I know about Flask WTF form but using this method will generate form on backend which is not my case.
from flask import Flask, request, url_for
...
@app.route("/data", methods=["GET", "POST"])
def get_data():
if request.method == "POST":
username = request.form["username"]
...
My html form:
<form method="POST" action="">
<input type="text" name="username">
<input type="submit" value="Send">
</form>
One hard way is to validate every field using regex and write several if conditions for them. I'm wondering for easier way?