skip to Main Content

I’m just getting started with VSCode and working through the
Flask Tutorial in Visual Studio Code

The 2nd example shows how to use app.route to go to a a default or a specific page:

@app.route("/")
def home():
    return "Hello, Flask!"

@app.route("/hello/<name>")
def hello_there(name):
    ...

While the first route works, the 2nd does not.

The first route works – I see "Hello Flask!" in my browser when I go to http://127.0.0.1:5000

The 2nd route does not work – I try to go to http://127.0.0.1:5000/hello/VSCode and I get:

Not Found, The requested URL was not found on the server…

Any ideas?

2

Answers


  1. Chosen as BEST ANSWER

    It turns out it's the usual problem that I typically forget to check. I simply terminated VSCode and restarted it and now it works. So it must have been some part of the run/debug testing inside VSCode that needed a restart after adding this code. I'm not sure exactly what the sequence of things inside VSCode would be to do that, but simply restarting the entire thing worked.


  2. It looks like you forgot the <name> in your second route. It shold look like this:

    @app.route("/hello/<name>")  # not "/hello/"
    def hello_there(name):
        ...
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search