Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flask-cdc-devlibx-0.0.8.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flask_cdc_devlibx-0.0.8-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file flask-cdc-devlibx-0.0.8.tar.gz.

File metadata

  • Download URL: flask-cdc-devlibx-0.0.8.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for flask-cdc-devlibx-0.0.8.tar.gz
Algorithm Hash digest
SHA256 7d1bbf37ac045dd77e4d71461e503b567630d2e6735fde1b4ad028e26be1aeb7
MD5 62a56000ae99ff9c44ffcde84af039f5
BLAKE2b-256 b022dd202cec3e385048bb791445ab9576530f8905db5a65ac2355d1ae4c0c84

See more details on using hashes here.

File details

Details for the file flask_cdc_devlibx-0.0.8-py3-none-any.whl.

File metadata

  • Download URL: flask_cdc_devlibx-0.0.8-py3-none-any.whl
  • Upload date:
  • Size: 5.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.10.1 pkginfo/1.8.2 requests/2.27.1 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.10

File hashes

Hashes for flask_cdc_devlibx-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 0c066e138bf6f562ba6a6294cc6cbfc19d969657efec65b5a32d1602840c9ed2
MD5 5527167be3bcb0ff05a7fc329dedfa60
BLAKE2b-256 98c6ba694fd8cc217840fa1a9686a6d21ef8e01bfff1ad232e0b5f99fc56a8e4

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page