The official Treblle SDK for JavaScript frameworks including Flask. Seamlessly integrate Treblle to manage communication with your dashboard, send errors, and secure sensitive data.
Treblle with Flask
Requirements
- requests
Examples
Basic Usage
You can use Treblle with Flask by importing the Treblle class and passing your Flask app to the constructor.
from treblle_flask import Treblle
app = Flask(__name__)
Treblle(app)
@app.route('/hello')
def hello():
return 'Hello, World!'Advanced Usage
You can also pass your Treblle API key and SDK Token to the Treblle constructor.
from treblle_flask import Treblle
app = Flask(__name__)
Treblle(app, TREBLLE_API_KEY="YOUR_API_KEY", TREBLLE_SDK_TOKEN="YOUR_SDK_TOKEN")
@app.route('/hello')
def hello():
return 'Hello, World!'Environment Variables
You can set the following environment variables to configure Treblle without passing any arguments to the Treblle constructor:
TREBLLE_API_KEY: Your Treblle API keyTREBLLE_SDK_TOKEN: Your Treblle SDK Token
Tip
Using environment variables is the recommended approach for managing your Treblle credentials, especially in production environments.