Skip to content

Instantly share code, notes, and snippets.

@K-Mistele
Last active November 12, 2020 16:30
Show Gist options
  • Save K-Mistele/95e8c3938e6f236b9f450ca22d52a8cf to your computer and use it in GitHub Desktop.
Save K-Mistele/95e8c3938e6f236b9f450ca22d52a8cf to your computer and use it in GitHub Desktop.
Using the CodeLighthouse error_catcher decorator with multiple users
from flask import Flask
# importing codelighthouse's SDK
from codelighthouse import CodeLighthouse
# configure the SDK
lighthouse = CodeLighthouse(
organization_name="Your organization name here",
x_api_key="your API key here",
resource_name="Sample Flask App", # the resource name is up to you
resource_group="Web Applications", # the resource group name is up to you
)
# create your app
app = Flask(__name__)
# create application routes
@app.route("/hello")
@codelighthouse.error_catcher(email="[email protected]")
def say_hello():
return "Hello!"
# note: the error_catcher decorator must sit directly "on top of" the function
@app.route("/hello/<name>")
@lighthouse.error_catcher(email="[email protected]")
def hello_name(name):
return "Hello, " + user_name + "!" # this will break
# run the app
app.run()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment