External Exam Download Resources Web Applications Games Recycle Bin

Parsing a Heterogeneous Python Tuple

j2_tuple.py

from flask import *
app = Flask(__name__)

datatuple = ("string", 100, ["itemA","itemB"])

@app.route("/")
def main():
    return render_template("template.html",data=datatuple)
    
app.run(debug=True)

templates\template.html

<!doctype html>

{% for each_field in data %}

  {{each_field}}<br>

{% endfor %}

<br>

{{data[1]}}

<br>

{{data[2][1]}}