semvec/pypi-packages huggingface dataset:
starlette-plugins 0.0.7
Create Starlette Plugins easier
License: MIT
Keywords: starlette plugins

Starlette-Plugins
#################

.. _description:

**starlette-plugins** -- A helper to make plugins faster with Starlette_

Starlette-Plugins is a helper to write plugins easier

.. _badges:

.. image:: https://github.com/klen/starlette-plugins/workflows/tests/badge.svg
    :target: https://github.com/klen/starlette-plugins/actions
    :alt: Tests Status

.. image:: https://img.shields.io/pypi/v/starlette-plugins
    :target: https://pypi.org/project/starlette-plugins/
    :alt: PYPI Version

.. _contents:

.. contents::

.. _requirements:

Requirements
=============

- python >= 3.7

.. _installation:

Installation
=============

**starlette-plugins** should be installed using pip: ::

    pip install starlette-plugins


Usage
=====

Let's imagine that we need to write Starlette plugins for Peewee ORM.

.. code:: python

    from aiopeewee import db_url

    from starlette_plugins import StarlettePlugin

    class Peewee(StarlettePlugin):

        # Give your plugin a name
        name = 'db'

        # Prepare a default configuration
        config = {
            'url': 'sqlite+async:///db.sqlite',
            'connection_params': {},
        }

    def __init__(self, app=None, **settings):
        super(Peewee, self).__init__(app, **settings)
        self.database = None

    def setup(self, app, **settings):
        """Setup the plugin."""
        super(Peewee, self).setup(app, **settings)
        self.database = db_url.connect(self.config.url, **self.config.connection_params)

    async def middleware(self, scope, receive, send, app):
        """An optional ASGI middleware."""
        try:
            await self.database.connect_async()
            await app(scope, receive, send)
        finally:
            await self.database.close_async()

    async def shutdown(self, scope):
        """ The methods are supported: `startup`, `shutdown`."""
        if hasattr(self.database, 'close_all'):
            self.database.close_all()


Use the plugin

.. code:: python

   from starlette.applications import Starlette


   db = Peewee(url='postgres+async://database')

   app = Starlette()
   db.setup(app)


.. _bugtracker:

Bug tracker
===========

If you have any suggestions, bug reports or
annoyances please report them to the issue tracker
at https://github.com/klen/starlette-plugins/issues

.. _contributing:

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

Development of the project happens at: https://github.com/klen/starlette-plugins

.. _license:

License
========

Licensed under a `MIT license`_.


.. _links:

.. _klen: https://github.com/klen
.. _MIT license: http://opensource.org/licenses/MIT
.. _Starlette: https://starlette.io
Sanic-HTTPAuth 0.2.0
Basic, Digest and Bearer token authentication for Sanic routes
License: MIT

Sanic-HTTPAuth
==============

[![Build Status](https://travis-ci.org/miguelgrinberg/Flask-HTTPAuth.png?branch=master)](https://travis-ci.org/miguelgrinberg/Flask-HTTPAuth)

This a fork of [Flask-HTTPAuth](https://github.com/miguelgrinberg/Flask-HTTPAuth) for Sanic. It is a simple extension that provides Basic and Digest HTTP authentication for Sanic routes.

Still a work in progress, contributions are welcome.

Installation
------------
The easiest way to install this is through pip.
```
pip install Sanic-HTTPAuth
```

Basic authentication example
----------------------------

```python
import hashlib
from sanic import Sanic, response
from sanic_httpauth import HTTPBasicAuth

app = Sanic(__name__)
auth = HTTPBasicAuth()


def hash_password(salt, password):
    salted = password + salt
    return hashlib.sha512(salted.encode("utf8")).hexdigest()


app_salt = "APP_SECRET - don't do this in production"
users = {
    "john": hash_password(app_salt, "hello"),
    "susan": hash_password(app_salt, "bye"),
}


@auth.verify_password
def verify_password(username, password):
    if username in users:
        return users.get(username) == hash_password(app_salt, password)
    return False


@app.route("/")
@auth.login_required
def index(request):
    return response.text(f"Hello, {auth.username(request)}!")


if __name__ == "__main__":
    app.run()
```

Note: See the [Flask-HTTPAuth documentation](http://pythonhosted.org/Flask-HTTPAuth) for more complex examples that involve password hashing and custom verification callbacks.

Digest authentication example
-----------------------------

```python
from sanic import Sanic, response
from sanic_httpauth import HTTPDigestAuth
from sanic_session import Session

app = Sanic(__name__)
app.config["SECRET_KEY"] = "secret key here"
auth = HTTPDigestAuth()
Session(app)

users = {"john": "hello", "susan": "bye"}


@auth.get_password
def get_pw(username):
    if username in users:
        return users.get(username)
    return None


@app.route("/")
@auth.login_required
def index(request):
    return response.text(f"Hello, {auth.username(request)}!")


if __name__ == "__main__":
    app.run()
```

Resources
---------

- [Flask-HTTPAuth Documentation](http://flask-httpauth.readthedocs.io/en/latest/)
- [PyPI](https://pypi.org/project/Sanic-HTTPAuth)
- [Change log](https://github.com/MihaiBalint/Sanic-HTTPAuth/blob/master/CHANGES.md)
pushgateway 0.1.13
A push gateway sending webthing properties updates to a openhab server
License: MIT
Keywords: webthings,home automation,openhab,push,gateway,web socket

# OpenhabWebThingPushGateway
A push gateway sending webthing properties updates to a openhab server

This project provides a background service connecting [webthing API](https://iot.mozilla.org/wot/)-based devices such as windsensors or motion detector to the [Openhab](https://www.openhab.org/) automation system. 

Internally, the service uses the web socket notification capability of the webthing api to listen for changes. If a webthing property is updated, the service will use the REST api of the Openhab installation 
to update the assoiciated Openhab item.

For each link (webthing property <-> openhab item association) an entry in a gateway config file has to be placed. E.g. a concrete config file may look like
```
# webthing_root_uri, webthing_property_name, openhab_root_uri, openhab_item_name
http://192.168.1.21:9131/, temperature, http://192.168.1.12:8080, TempCurrent
http://192.168.1.21:9132/, windspeed, http://192.168.1.12:8080, WindspeedCurrent
http://192.168.1.187:9045/, motion, http://192.168.1.12:8080, MotionGroundfloor
```
The first entry is the webthing endpoint uri, the second the property name to be linked. 
The third parameter is the endpoint uri of the openhab installation, and the fourth parameter is the item name 
(which may differ from the webthing property name)      

To service can be started manually via command line using
```
sudo pushgateway --command listen --filename /etc/pushgateway/gateway.conf
```
 
Alternatively to the *listen* command, you can use the *register* command to register and start the service as systemd unit. 
By doing this the service will be started automatically on boot. Starting the server manually using the *listen* command is no longer necessary. 
```
sudo pushgateway --command register --filename /etc/pushgateway/gateway.conf
```  

To install this software you may use [PIP](https://realpython.com/what-is-pip/) package manager such as shown below
```
sudo pip install pushgateway
```