0

So I'm currently working on pset7 survey and am about to finish. I just have to display my table in sheet.html. When run, I only get the headers right and afterwards I get nothing. Am I doingsomething wrong here?

get_sheet code:

SHEET = []
@app.route("/sheet", methods=["GET"])
def get_sheet():
    with open("survey.csv", mode="r") as survey_csv:
        survey_reader = list(csv.reader(survey_csv))
        for row in survey_reader:
            SHEET.append(survey_reader)
        return render_template("sheet.html")

Sheet.html code:

{% extends "layout.html" %}

{% block main %}
    <table class="table">
        <thead>
            <th scope="col">Name</th>
            <th scope="col">Age</th>
            <th scope="col">Faction</th>
        </thead>
        <tbody>
        {% for row in SHEET %}
            <tr>
                {% for element in row %}
                    <td> {{element}} </td>
                {% endfor %}
            </tr>
        {% endfor %}
{% endblock %}
1

You need to pass SHEET to the template in your render_template call.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .