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

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:

<link rel="shortcut icon" href="https://stackoverflow.com/questions/31766082/{{ url_for("static', filename="favicon.ico") }}">

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

Leave a Comment

tech