semvec/pypi-packages huggingface dataset:
Flask-pyWebPush 1.1
A clean interface to pywebpush from Flask
License: MIT
Requires Python: >= 3.6

# Flask-pyWebPush

[![PyPI version shields.io](https://img.shields.io/pypi/v/flask-pywebpush.svg)](https://pypi.python.org/pypi/flask-pywebpush/)

A clean interface to `pywebpush` from Flask. Basically, a very thin wrapper.

## Installation

The package is available [at the PyPI](https://pypi.org/project/Flask-pyWebPush/):

```bash
$ pip install flask-pywebpush
```

## Quickstart

### Instantiation

Instantiate this extension like any other Flask extension:

```python
from flask_pywebpush import WebPush
app = Flask()
push = WebPush(app)
```

Or you may initialize the extension with the Flask instance later:

```python
from flask_pywebpush import WebPush
app = Flask()
push = WebPush()
push.init_app(app)
```


### VAPID keys and sender info

WebPush sender requires a private key and an identification URL to operate. For more information on those values, see [this article on Google Developers](https://developers.google.com/web/fundamentals/push-notifications/subscribing-a-user#how_to_create_application_server_keys).

You may specify these values to the extension by setting the following configuration variables of the Flask instance:

* `WEBPUSH_VAPID_PRIVATE_KEY`
  The application server private key. As with `pywebpush`, it may either be the literal key value (DER representation) or a path to a VAPID EC2 private key PEM file;
* `WEBPUSH_SENDER_INFO`: a URL containing information to contact the notification sender. Commonly a mailto: URL.

Alternatively, you can pass these values on creation of the `WebPush` extension instance or to the `init_app` method later on:

```python
from flask_pywebpush import WebPush
push = WebPush(private_key='some_value',
               sender_info='mailto:admin@server.com')
```

### Notification sending

Assuming you've got the subscription storage done, you may send a notification to a given subscription object like so:

```python
from flask_pywebpush import WebPushException

subscription = {
    'endpoint': '---some-value---',
    'keys': { ... }
}
notification = {
    'title': 'Test',
    'body': 'notification body',
}

try:
    push.send(subscription, notification)
except WebPushException as exc:
    print(exc)
```

You can also pass keyword arguments like `verbose=True` to `.send()`, which will be directly passed to `pywebpush.webpush()`


## Extended Usage

Since this is a wrapper over `pywebpush`, it exposes the main objects of the underlying library, namely, `webpush`, `WebPushException`, `WebPusher`.  
All of them may be directly imported from `flask_pywebpush`.

The `WebPush` extension instance also has a `get_webpusher(subscription)` method, allowing you to get a `pywebpush.WebPusher` instance for a given subscription.

If your usage requires more VAPID claims than simply `{"sub": "sender_info"}`, then you may override the passed claims using the `set_claims` method:

```python
from flask_pywebpush import WebPush
push = WebPush()
push.set_claims({})  # whatever VAPID claims you might need
```

## License

[MIT](https://github.com/illright/flask-webpush/blob/master/LICENSE)
circuitpython-hmac 0.2.1
HMAC (Keyed-Hashing for Message Authentication) Python module. Implements the HMAC algorithm as described by RFC 2104.
License: MIT
Keywords: adafruit blinka circuitpython micropython hmac hashing authentication message

Introduction
============

.. image:: https://readthedocs.org/projects/circuitpython-hmac/badge/?version=latest
    :target: https://circuitpython.readthedocs.io/projects/hmac/en/latest/
    :alt: Documentation Status

.. image:: https://img.shields.io/discord/327254708534116352.svg
    :target: https://discord.gg/nBQh6qu
    :alt: Discord

.. image:: https://github.com/jimbobbennett/CircuitPython_HMAC/workflows/Build%20CI/badge.svg
    :target: https://github.com/jimbobbennett/CircuitPython_HMAC/actions
    :alt: Build Status

.. image:: https://img.shields.io/badge/code%20style-black-000000.svg
    :target: https://github.com/psf/black
    :alt: Code Style: Black

HMAC (Keyed-Hashing for Message Authentication) Python module. Implements the HMAC algorithm as described by RFC 2104.


Dependencies
=============
This driver depends on:

* `Adafruit CircuitPython <https://github.com/adafruit/circuitpython>`_
* `Adafruit CircuitPython Hashlib <https://github.com/adafruit/Adafruit_CircuitPython_hashlib>`_

Please ensure all dependencies are available on the CircuitPython filesystem.
This is easily achieved by downloading
`the Adafruit library and driver bundle <https://circuitpython.org/libraries>`_.

Installing from PyPI
=====================

On supported GNU/Linux systems like the Raspberry Pi, you can install the driver locally `from
PyPI <https://pypi.org/project/circuitpython-hmac/>`_. To install for current user:

.. code-block:: shell

    pip3 install circuitpython-hmac

To install system-wide (this may be required in some cases):

.. code-block:: shell

    sudo pip3 install circuitpython-hmac

To install in a virtual environment in your current project:

.. code-block:: shell

    mkdir project-name && cd project-name
    python3 -m venv .env
    source .env/bin/activate
    pip3 install circuitpython-hmac

Usage Example
=============

Create a keyed hash for authenticating a message.

.. code-block:: python

    secret = "secret"
    msg = "message"

    key = hmac.new(secret, msg=msg, digestmod=hashlib.sha256).digest()

Contributing
============

Contributions are welcome! Please read our `Code of Conduct
<https://github.com/jimbobbennett/CircuitPython_HMAC/blob/master/CODE_OF_CONDUCT.md>`_
before contributing to help this project stay welcoming.

Documentation
=============

For information on building library documentation, please check out `this guide <https://learn.adafruit.com/creating-and-sharing-a-circuitpython-library/sharing-our-docs-on-readthedocs#sphinx-5-1>`_.