Flask.url_for() error: Attempted to generate a URL without the application context being pushed

后端 未结 3 709
隐瞒了意图╮
隐瞒了意图╮ 2020-12-16 10:53

I have a trivial app where I\'m trying to redirect the favicon per:

http://flask.pocoo.org/docs/0.10/patterns/favicon/

app = flask.Flask(__name__)
ap         


        
3条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-16 11:04

    According to the doc:

    Setting a SERVER_NAME also by default enables URL generation without a request context but with an application context.

    since you're using app_context, you may set the SERVER_NAME Configuration Value.

    By the way, as the doc:Adding a favicon says:

    
    

    the above line should be enough for most browsers, we don't have to do any other things.

提交回复
热议问题