Forums

Flask HTML output list object records row by row

Hi All, is there an easy way of outputting all records from a list object into html , row by row?
For example I've got a python list called 'results' - currently im displaying it only in one row : <p>The result is {result}</p>

I would like to do something like this : {% for x in results %} <div class="row"> {{ x }} </div> {% endfor %}**

but can't get this to work within flask.app file (error log file tells me that the above generate an error - but I'm not sure what the exact error is or how to change this to make it work)

This is the part of the code (borrowed from your tutorial) I want to amend

return ''' <html> <body>

                <p>The result is {result}</p>
                <p><a href="/">Click here to analyse another text</a>
            </body>
        </html>
    '''.format(result=results)

Any ideas? please let me know if you need more information (my first post here). Thanks

:::text {% for x in results %} <div class="row"> {{ x }} </div> {% endfor %}

should work. Assuming that results is defined and is a list. The error is telling you what's wrong, so start there to debug.