Flask tutorial - 404 Not Found

后端 未结 2 786
你的背包
你的背包 2021-01-11 13:51

I just finished the Flask basic tutorial (here) and even though I\'ve done completed every step, when I am trying

python flaskr.py

what I get

相关标签:
2条回答
  • 2021-01-11 14:22

    You put your app.run() call too early:

    if __name__== '__main__':
        app.run()
    

    This is executed before any of your routes are registered. Move these two lines to the end of your file.

    Next, you have the first line in show_entries() is incorrect:

    def show_entries():
        db_get_db()
    

    There is no db_get_db() function; this should be db = get_db() instead.

    0 讨论(0)
  • 2021-01-11 14:27

    Happened to me also while following Flask Application Setup here . The error was gone after appending a trailing slash at the end of the route.

    @app.route('/hello')
        def hello():
            return 'Hello, World!'
    

    was changed to

    @app.route('/hello/')
        def hello():
            return 'Hello, World!'
    

    and the problem was solved. Hope it helps for anyone who is searching for a problem like this.

    0 讨论(0)
提交回复
热议问题