Forums

flask tutorial, problem with for loop and 403 error

I'm trying to complete the beginner's Flask tutorial, but I'm running into two issues:

a. this section of the tutorial doesn't seem to be working right. I.e., when i load the html page, it prints this info instead of executing it (i know the divs are missing tags; they wouldn't show up otherwise here, but they are there in my file:

{% for comment in comments %} div class="row"> {{ comment }} /div> {% endfor %}

b. when i try to submit a comment i get the following error: Forbidden (403) CSRF verification failed. Request aborted. More information is available with DEBUG=True.

I copied and pasted the tutorial code when I couldn't find any errors in my own and I still get the same results. Any help would be much appreciated.

(i also posted this on stackoverflow)

I * think* i figured out the problem. I was using this to display:

https://www.pythonanywhere.com/user/swanstro/files/home/swanstro/mysite/templates/main_page.html

instead of this? http://swanstro.pythonanywhere.com/

not sure if that is right, but at least it seems to be working now!

Right. that first link is actually only available to you (when you are logged in to pythonanywhere). ie. it's just you opening a file from the file browser.

The second link is your actual website!