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

Uploaded Source

Built Distribution

formsg-0.1.8-py3-none-any.whl (5.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: formsg-0.1.8.tar.gz
  • Upload date:
  • Size: 4.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1039-azure

File hashes

Hashes for formsg-0.1.8.tar.gz
Algorithm Hash digest
SHA256 8beee423bedc34636e23fddbc55723b9448adec1b1d131b6ca264609fa5c7930
MD5 f93af9e7156be8f153ad5b30a45735a5
BLAKE2b-256 96821e3861f2e74c29cf5aa7d98a7580bd1f10f9f55744973c087ba053ce5383

See more details on using hashes here.

File details

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

File metadata

  • Download URL: formsg-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 5.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1039-azure

File hashes

Hashes for formsg-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 42b908ae8a94ac658cf95c824e96a82a366e5ae5e52f3fe3e476161bab0a1cbc
MD5 78f99247ae46f4eee1c2d4323008d5af
BLAKE2b-256 8001408156822d2b02630b5784c9cbab5787875bbb1914cde9f08c64a1119f54

See more details on using hashes here.

Supported by

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