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

Uploaded Source

Built Distribution

formsg-0.1.4-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: formsg-0.1.4.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for formsg-0.1.4.tar.gz
Algorithm Hash digest
SHA256 a87524bec001c5f13aac982e7062b8c08002e7a7c7f34a2b02011407fb91301c
MD5 c9109e6067aecc707989d1f201506730
BLAKE2b-256 3d7d1103a5fd71c5000fdbb0d7dd3b02c1cf023ac9398a433afb78ee6534964e

See more details on using hashes here.

File details

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

File metadata

  • Download URL: formsg-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/4.8.2 pkginfo/1.8.2 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for formsg-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 e709a20057929576702a28e87fab9624e7f9ed064dff944054f29873b947f4fe
MD5 9b507571fc6fbba659d43b241240fa23
BLAKE2b-256 3dcfda0cbf209abe3d6a8bb994194eb02970f9b11f9597ec879ea458e11ff9eb

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