An demo Flask application that sends websocket messages to the browser originating from the Linux DBUS, in this case from the UPower daemon. There is only one relevant page in this demo so far, which shows the battery status of the host it is run on.
This only works on Linux, was originally developed on Ubuntu 13.10, but also works on Ubuntu 14.04.
See provision.sh
for basic python and system dependencies.
virtualenv -p python3 venv
source venv/bin/activate
pip install -r requirements.txt
A sample Vagrantfile
is provided to get started on Ubuntu 14.04 and 16.04.
Start the webservice:
python run.py 0.0.0.0
- DBUS
- python2.7+ or python3.5+ (not sure about the versions in between, I never tried)
- python-dbus didn't work for this, because it can't be run in a subthread while still using its main loop
https://pypi.python.org/pypi/python-tdbus
http://upower.freedesktop.org/
Linux Journal article on DBUS: http://www.linuxjournal.com/article/10455?page=0,0