Skip to main content

A Python SDK for handling FormSG webhooks.

Project description

FormSG Python SDK

PyPI version PyPI license PyPI pyversions PyPI status PyPI download total

This SDK provides convenient utilities for verifying FormSG webhooks and decrypting submissions in Python and Flask or Django.

Installation

pip install formsg

Usage

The SDK provides two main utility functions for handling FormSG webhook:

For convenience, the SDK implements a decrypt_django_request and decrypt_flask_request which returns the decrypted FormSG content from a Django/Flask request object directly.

Example with Flask

from formsg.flask import decrypt_flask_request

from flask import Flask
from flask import jsonify
from flask import request

app = Flask(__name__)


@app.route('/formsg_webhook', methods=['POST'])
def formsg_webhook():
    decrypted = decrypt_flask_request(
        request,
        secret_key='xxx',
        webhook_uri='https://xxx.ngrok.io/formsg_webhook',  # we use ngrok to test our webhooks locally
    )

    return jsonify(decrypted)
#end def


if __name__ == '__main__':
    app.run(debug=True)
#end if

Contributions

If you find any issues or would like to contribute improvements, please feel free to raise them in this repository directly.

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

formsg-0.1.7.tar.gz (4.1 kB view details)

Uploaded Source

Built Distribution

formsg-0.1.7-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file formsg-0.1.7.tar.gz.

File metadata

  • Download URL: formsg-0.1.7.tar.gz
  • Upload date:
  • Size: 4.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

File hashes

Hashes for formsg-0.1.7.tar.gz
Algorithm Hash digest
SHA256 e2bf315226718492ab94fa1217563e7dc48de6525f8ec20416d9e34c1e755d0c
MD5 7e23dd4caebe13b13173e7b565f98eb1
BLAKE2b-256 83594fbee996c86202d45f83519cbc85ba8e60e7bde7330df3e59e31a0566b56

See more details on using hashes here.

File details

Details for the file formsg-0.1.7-py3-none-any.whl.

File metadata

  • Download URL: formsg-0.1.7-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Darwin/22.5.0

File hashes

Hashes for formsg-0.1.7-py3-none-any.whl
Algorithm Hash digest
SHA256 f796af5b3e246788a74d7a17465d65b008488075bb81d3511499d43a9235db48
MD5 4c67e0f649c728ffed6bd31d3bae5553
BLAKE2b-256 db1921222c48b124be3a6ac9d0ae25f7847440fe72a6a7ae2ca291c9d11fe463

See more details on using hashes here.

Supported by

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