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.6.tar.gz (4.7 kB view details)

Uploaded Source

Built Distribution

formsg-0.1.6-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: formsg-0.1.6.tar.gz
  • Upload date:
  • Size: 4.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for formsg-0.1.6.tar.gz
Algorithm Hash digest
SHA256 9d08f9988291df7618a99932527dce72c2ee266dbb75e134a69166e4024c50c4
MD5 3a1e4aec9ecd1d587ea7a79431e9fd5a
BLAKE2b-256 9512a988cff6258e3d539b7e704b8c383d1aa08aa84d9e3813c166aa9d7cdb8d

See more details on using hashes here.

File details

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

File metadata

  • Download URL: formsg-0.1.6-py3-none-any.whl
  • Upload date:
  • Size: 5.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.8.0 pkginfo/1.8.2 readme-renderer/32.0 requests/2.27.1 requests-toolbelt/0.9.1 urllib3/1.26.8 tqdm/4.62.3 importlib-metadata/4.11.0 keyring/23.5.0 rfc3986/2.0.0 colorama/0.4.4 CPython/3.10.2

File hashes

Hashes for formsg-0.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 d7d64dace0b4290d21eb2ac703e8be0bd9641f00a86945ab69573359e93338e1
MD5 99b0b69513a1e7c0dc167ab6a5254eb5
BLAKE2b-256 d445adebcf80604bdcf81ccb618f1eb315ee6b19b8263d116957bbb7f544c1ac

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