Changed to @app.before_request.