Answer the question
In order to leave comments, you need to log in
How to process data from a form using Python (flask)?
Good afternoon.
There is an html with a form and script.py. Flask framework.
How to pass data from input to a function as an argument?
And how to output the data parsed by the script back to html?
thank.
Answer the question
In order to leave comments, you need to log in
I found the answer to the first half of the question here: stackoverflow.com/questions/12277933/send-data-fro...
You can pass it to a function like this (the code of one of the www.habr-analytics.com/user
functions )
@app.route('/userfig/<name>/<datatype>')
def userfig(name,datatype):
name = str(name.strip().lower())
# unsupported operation
if datatype not in datatypes:
return
.....
@app.route('/user/', methods=['GET'])
def user():
name = request.args.get('name')
datatype = request.args.get('datatype')
data_title = None
if datatype in datatypes:
data_title = datatypes_to_title[datatype]
return render_template("user.html", usernameform=usernameform, name=name, datatype=datatype, datatypes=datatypes, data_title = data_title)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question