Skip to main content

DeviceHive Python web configurator

Project description

License

Devicehive python web configurator

This is proxy package for devicehive-python that provides simple web interface to configure connection.

Installation

pip install devicehive-webconfig

Usage

Basics

Web interface based on python HttpServer and implements Devicehive connection in separated thread.
It takes Handler class as argument like original Devicehive class.
Only difference that extended Handler class from this repository must used.
Server could be runned in non-blocking mode, so main thread is free to use.
Example:
import time
import json

from devicehive_webconfig import Server, Handler


class ExampleHandler(Handler):
    _device = None

    def handle_connect(self):
        self._device = self.api.put_device(self._device_id)
        super(ExampleHandler, self).handle_connect()

    def send(self, data):
        self._device.send_notification(data)


if __name__ == '__main__':
    server = Server(ExampleHandler, is_blocking=False)
    server.start()

    print('Go to http://127.0.0.1:8000/ and configure your connection.')
    while not server.dh_status.connected:
        # Wait till DH connection is ready
        time.sleep(.001)

    for i in range(10):
        server.deviceHive.handler.send('notification #{}'.format(i))

Additional Handler arguments can be passed as args and kwargs

Advanced

This library was designed to be easily extended. Additional routes, controllers, templates and static files can be added. There is an example that shows how this can be done.

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

devicehive_webconfig-1.0.2.tar.gz (66.8 kB view details)

Uploaded Source

File details

Details for the file devicehive_webconfig-1.0.2.tar.gz.

File metadata

File hashes

Hashes for devicehive_webconfig-1.0.2.tar.gz
Algorithm Hash digest
SHA256 3e1c7e852f37de94325f6423cffb98614374356650af8fe5fdddeace999057b8
MD5 bbb0497328c887554d374c377c2b6e24
BLAKE2b-256 1cd726108c01f8ce4b814a4da83af3508968cb5d8f75ce0e8a8b0abe916de907

See more details on using hashes here.

Supported by

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