Flask 2.3.0 removed `before_first_request` decorator
mikhail-tokarev opened this issue · 1 comments
mikhail-tokarev commented
as new Flask version was released on 25 April (https://flask.palletsprojects.com/en/2.3.x/changes/#version-2-3-0) the Flask example is not valid anymore.
What the best way to use rollbar with the latest Flask?
danielmorell commented
Hi @mikhail-tokarev, thank you for pointing that out.
Here is a pretty simple setup that will capture errors in a Flask v2.3 app.
from pathlib import Path
from flask import Flask
import rollbar
from rollbar.contrib.flask import report_exception
from flask import got_request_exception
app = Flask(__name__)
with app.app_context() as ctx:
rollbar.init(
'<access_token>',
'<env>',
# Other configs
)
got_request_exception.connect(report_exception, ctx.app)
@app.index("/")
def index():
not_a_real_function() # This should cause an error.
return "<h1>Hello, World!</h1>
I will circle back and make sure our examples get updated.