Flask return multiple variables?
<p>I am learning Flash with Python. My python skills are okay, but I have no experience with web apps. I have a form that takes some information and I want to display it back after it is submitted. I can do that part, however I can only return one variable from that form even tho there are 3 variables in the form. I can return each one individually but not all together. If I try all 3, I get a 500 error. Here is the code I am working with:</p>

<pre><code>from flask import Blueprint
from flask import render_template
from flask import request

simple_page = Blueprint('simple_page', __name__)

@simple_page.route('/testing', methods=['GET', 'POST'])
def my_form():
        if request.method=='GET':
            return render_template("my-form.html")
        elif request.method=='POST':
            firstname = request.form['firstname']
            lastname = request.form['lastname']
            cellphone = request.form['cellphone']
            return firstname, lastname, cellphone
</code></pre>

<p>If I change the last return line to:</p>

<pre><code>return firstname
</code></pre>

<p>it works, or:</p>

<pre><code>return lastname
</code></pre>

<p>or:</p>

<pre><code>return cellphone
</code></pre>

<p>If I try two variables it will only return the first, once I add the 3rd I get the 500 error. I am sure I am doing something silly, but even with tons of googling I could not get it figured out. Any help would be great. Thank you.</p>

<p>Flask requires either a <code>str</code> or <code>Response</code> to be return, in you case you are attempting to return a <code>tuple</code>.</p>

<p>You can either return your <code>tuple</code> as a formatted <code>str</code></p>

<pre><code>return  '{} {} {}'.format(firstname, lastname, cellphone)
</code></pre>

<p>Or you can pass the values into another <code>template</code></p>

<pre><code>return render_template('my_other_template.html', 
                       firstname=firstname,
                       lastname=lastname,
                       cellphone=cellphone)
</code></pre>

python flask