[Tourists Attractions] Build Python Web Apps with Flask - How to make Step 10 work

Hello, I’m working on Tourist Attractions:

I’m on step 10, where you have to make the buttons do their job (deleting or moving up a catergory)
My code looks like this:

def locations(category):

  locations = visit.get_list_by_category(category)

  if request.method == "Post":

    [(name, action)] = request.form.items()

    if action == UP_ACTION:


    elif action == DEL_ACTION:


  return render_template("locations.html", category=category, categories=categories, locations=locations)

I don’t get any errors, but also the buttons don’t work. According to the instructions they should be working, and I cannot find why they don’t do anything. What did I miss? Or did I do something wrong?

Thanks in advance for any help :slight_smile:

Always check if the return if your conditionals in these scenarios before the conditional to see if it’s being triggered. It’ll be printed on your terminal for debugging.

(i.e.: `print(request.method == “Post”))

Let me know if you can’t figure it out after that.

Hey @text2840483046 it’s been a little while since you originally posted this question. Could you come back to let us know if the above reply helped you?

The reply did help a bit, although I couldn’t figure out how to print anything, since in the output you are creating a webpage, and there nothing is printed in the same way as when you use python. Or at least I don’t know how to do that… :thinking:

But I found my error, so now it’s working fine :slight_smile:

That’s a great point. I didn’t realize in the flask course you don’t have access to the terminal!

It’s a very good reason to try to host your flask projects locally so that you can get rich feedback messages from the terminal.

Yes, this indeed prompted me to set up my local coding environment, so that I can also use the terminal for thing like this. It really helps!