Python DSL for setting up Flask app CDC
Project description
This is a helper module to allow you to capture all the request/response which comes to your Flask app.
pip install flask-cdc-devlibx
How to use
from flask_cdc import cdc
# We expect you already have the flask app
app = "Existing flask"
# Recorder is called everytime you get request response. You can do anything you want
# In this example we have logged data with a helper function provided by cdc. You can change
# this method to do anything else
def recorder(state):
cdc.log_results(state)
# Wrap app to your session record MW
app.wsgi_app = cdc.SessionRecorderMiddleware(app.wsgi_app, recorder)
How to enable CDC
Set following env variable:
export CDC_KAFKA=<your kafka broker>
export CDC_TOPIC=<your kafka topic for CDC>
You can use the pre-defined recorder to send data to kafka:
app.wsgi_app = cdc.SessionRecorderMiddleware(app.wsgi_app, cdc.publish_result_to_kafka)
Once it is defined then you can see the following data in your topic
{
"request": {
"body": {
"archive_existing_versions": true,
"name": "harish",
"stage": "Staging",
"version": "2"
},
"method": "POST",
"url": "/ajax-api/2.0/preview/mlflow/model-versions/transition-stage"
},
"response": {
"status": "200 OK"
}
}
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file flask-cdc-devlibx-0.0.11.tar.gz
.
File metadata
- Download URL: flask-cdc-devlibx-0.0.11.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6d28388e5187455496fecaa176782b601db81909b1212a7f64f2046f7114411a |
|
MD5 | b001dddf9c24147b9303a58419277451 |
|
BLAKE2b-256 | 75975c656709808e64e22c3ec1b6056a3b8bc267ab23bb6327970893997a0480 |
File details
Details for the file flask_cdc_devlibx-0.0.11-py3-none-any.whl
.
File metadata
- Download URL: flask_cdc_devlibx-0.0.11-py3-none-any.whl
- Upload date:
- Size: 5.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.1 CPython/3.9.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e2ed71f9af277d6505b66ac44b6100e4a7045adfdd59bba05194d1bd9bf2a01b |
|
MD5 | e3dfc7e1efe4ac7963da9ff0bd3cc5d1 |
|
BLAKE2b-256 | 03d4a7d0bd227a927eece31ecc8a3f35104f540917fe3aaa94280b24169fd885 |