Last active
November 12, 2020 16:26
-
-
Save K-Mistele/9ca40dfb102962ebec60a9060217c04a to your computer and use it in GitHub Desktop.
Integrating CodeLighthouse into our example Flask app
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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