Flask tutorial - 404 Not Found

别说谁变了你拦得住时间么 提交于 2019-12-01 15:48:46

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.

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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!