Skip to content

Instantly share code, notes, and snippets.

@K-Mistele
Last active November 12, 2020 16:26
Show Gist options
  • Save K-Mistele/9ca40dfb102962ebec60a9060217c04a to your computer and use it in GitHub Desktop.
Save K-Mistele/9ca40dfb102962ebec60a9060217c04a to your computer and use it in GitHub Desktop.
Integrating CodeLighthouse into our example Flask app
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")
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="your account's email address here")
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