Skip to content

Lightrun for Flask

In order to run a Flask web app with the Lightrun agent please follow these steps:

  • In the application folder, install the python agent by running python -m pip install lightrun
  • Add the following code to your application's main init.py or app.py (the import shouldn't be added to a specific routed method, but to the main file code instead):
try: 
    import lightrun
    lightrun.enable(com_lightrun_server='https://app.lightrun.com/company/<COMPANY-NAME>', com_lightrun_secret='<COMAPNY-SECRET>')
except ImportError as e:
    print("Error importing Lightrun: ", e)

# Example route
@app.route("/")
def hello_world():
    return "<p>Hello world!</p>"

Last update: September 27, 2021