python - Can't return multiple values from this Flask view -


the following view return smead not return second string. when try return variable john, 500 error. how fix view return right thing?

from flask import flask, render_template  app = flask(__name__)  @app.route('/') def homepage():     return render_template("main.html")  @app.route('/test/', methods=["get","post"]) def test():     import re     text = "testereread"     john = re.findall(r'test(.*)$', text)     smead = "testererere"     return smead     return "i swear no workiez"  if __name__ == "__main__":     app.run() 

the first issue can return once function, return smead function ends , doesn't return next string.

the second issue re.findall returns list. flask doesn't know list returned view, throws error. can return string or response view.

what want render template values.

return render_template('test', smead=smead, other='it works', john=john) 
<p>{{ smead }}: {{ other }}</p> <ul>{% item in john %}     <li>{{ item }}</li> {% endfor %} 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

php - Find a regex to take part of Email -