Skip to main content

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.

Metadata

Release files for formsg 0.1.8

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for formsg 0.1.8
File Size Uploaded Provenance Actions
formsg-0.1.8.tar.gz 4.4 kB Without provenance Details for formsg-0.1.8.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for formsg 0.1.8
File Interpreter ABI Platform Actions
formsg-0.1.8-py3-none-any.whl Python 3 none any Details for formsg-0.1.8-py3-none-any.whl

Total release size: 9.9 kB

Release files / formsg-0.1.8.tar.gz

Download URL formsg-0.1.8.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8beee423bedc34636e23fddbc55723b9448adec1b1d131b6ca264609fa5c7930
BLAKE2b-256 checksum
How to use checksums
96821e3861f2e74c29cf5aa7d98a7580bd1f10f9f55744973c087ba053ce5383
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1039-azure

Release files / formsg-0.1.8-py3-none-any.whl

Download URL formsg-0.1.8-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
42b908ae8a94ac658cf95c824e96a82a366e5ae5e52f3fe3e476161bab0a1cbc
BLAKE2b-256 checksum
How to use checksums
8001408156822d2b02630b5784c9cbab5787875bbb1914cde9f08c64a1119f54
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.5.1 CPython/3.11.0 Linux/5.15.0-1039-azure

Security for formsg 0.1.8

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page