Skip to main content

flask-botox

Flask extension that ties boto3 connectors to the application context. To be used with Python 3.7+.

Install

  • Via pip:

    $ pip install flask-botox
    
  • Locally with Poetry for development purposes:

    $ git clone https://github.com/jperras/flask-botox.git
    $ cd flask-botox
    $ poetry install
    

How-to

The main class flask_botox.Boto3 takes a Flask application as its contructor's parameter:

from flask import Flask
from flask_botox import Boto3
app = Flask(__name__)
app.config["BOTOX_SERVICES"] = ["s3", "ses", "sqs"]

botox = Boto3(app)

The application factory pattern for extensions is also valid:

from flask import Flask
from flask_botox import Boto3

botox = Boto3()

app = Flask(__name__)
app.config["BOTOX_SERVICES"] = ["s3", "ses", "sqs"]

botox.init_app(app)

Then boto3's clients and resources will be available as properties within the application context:

>>> with app.app_context():
        print(botox.clients)
        print(botox.resources)
{'s3': <botocore.client.S3 object at 0x..>}
{'s3': s3.ServiceResource()}

Configuration

Flask-botox uses several keys from a Flask configuration objects to customize its behaviour. Any of the AWS_* keys are not required; if they are not specified, then the usual boto3 configuration parameter rules will apply.

  • AWS_ACCESS_KEY_ID & AWS_SECRET_ACCESS_KEY : The AWS credentials. Note that it's not a good idea to put your secret access key in a configuration file, but it can be useful for e.g. testing purposes.
  • AWS_DEFAULT_REGION : The region, e.g. us-east-1, for the boto3 AWS services.
  • AWS_PROFILE : The AWS nanmed profile to use, if one is desired.
  • BOTOX_SERVICES : The name of the AWS resources you want to use, e.g. ['sqs', 's3', 'ses'].
  • BOTOX_OPTIONAL_PARAMS : Useful if you need to pass additional parameters to the client/resource connections, e.g. a custom endpoint_url for a particular service. The format is a dict where the top-level keys are the name of the services you're using and for each the value is a dict containing to keys args (contains the parameters as tuple) and kwargs (contains the parameters as a dict when they should be passed as keyword arguments).

Metadata

Release files for flask-botox 0.1.1

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

Source distribution (sdist)

Source distribution for flask-botox 0.1.1
File Size Uploaded Provenance
flask-botox-0.1.1.tar.gz 4.8 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for flask-botox 0.1.1
File Interpreter ABI Platform
flask_botox-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 10.4 kB

Release files / flask-botox-0.1.1.tar.gz

Download URL flask-botox-0.1.1.tar.gz
Size 4.8 kB
Tags Source
SHA-256 checksum
How to use checksums
38325263b26c5bd64ebe4d230264efb3e8d81294036b67ea2aa1207b4473b57e
BLAKE2b-256 checksum
How to use checksums
438548b8a579f0e22d80f9e4a8f911131c693cca986289a6096562087971a4e5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.10.5 Darwin/21.4.0

Release files / flask_botox-0.1.1-py3-none-any.whl

Download URL flask_botox-0.1.1-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0fd70201e0984e1ed21d1aea2985a2a4134bb82e72bae6892d1a654ab72fc6de
BLAKE2b-256 checksum
How to use checksums
f31854df3b98a161fc8aa9dacace7b06202da7dc76914120568677444e285ac4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.1.14 CPython/3.10.5 Darwin/21.4.0

Security for flask-botox 0.1.1

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.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files No provenance

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