Metadata-Version: 2.1
Name: http-plot-server
Version: 0.1
Summary: A simple and lightweight http server to visualize measurements
Home-page: https://github.com/qbee-io/plot_server
Author: qbee.io
Author-email: pypi@qbee.io
License: MIT
Project-URL: qbee Homepage, https://qbee.io/
Project-URL: qbee Docs, https://qbee.io/docs/
Project-URL: Source, https://github.com/qbee-io/plot_server
Keywords: plot server,visualization,plotly,http,measurements
Platform: UNKNOWN
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Customer Service
Classifier: Intended Audience :: End Users/Desktop
Classifier: Intended Audience :: Information Technology
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: POSIX :: Linux
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.5
Classifier: Programming Language :: Python :: 3.6
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: JavaScript
Classifier: Topic :: Scientific/Engineering :: Visualization
Classifier: Topic :: Internet :: WWW/HTTP :: HTTP Servers
Classifier: Topic :: Text Processing :: Markup :: HTML
Requires-Python: >=3.5, <4
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: python-dateutil

# plot_server
A lightweight http plot server written in python to visualize data locally. Storing only a fixed number of data points (100 per default) per measurement to keep the resources low.

Empty plot                 |  Selectable data
:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/qbee-io/plot_server/main/img/empty_plot.png)  | ![](https://raw.githubusercontent.com/qbee-io/plot_server/main/img/two_plots.png)

## Quickstart
Install the package via pip
```
pip3 install http-plot-server
```

Adapt the settings in param.cfg to your needs and run

```
plot_server --cfg=param.cfg
```
or run the module as
```
python3 -m plot_server --cfg=param.cfg
```
and open your browser with the specified port, per default:
```
http://localhost:8080
```

You can also leave out the cfg flag and default values will be used.

## Command line options
* `--host`: specifies the host (default: 0.0.0.0), can be `localhost` to avoid access from outside
* `--port`: specifies the port the server runs on (default: 8080)
* `--max-points`: specifies the maximum number of data points the plot server stores per measurement (default: 100)
* `--cfg`: specifies the path to a config file containing the above command line arguments (see `misc/param.cfg`)

## How to feed data to the plot_server
You can add data points to the plot_server by a simple http POST request including the json payload

``` json
{
    "tag": "Measurement Name",
    "value": 1234,
    "unit": "W",
    "ts": 1649859909
}
```

Where `unit` and `ts` are optional. If `ts` is not provided, then the time is used at which the post request is made. If `unit` is not provided, then the plot_server simply displays "Value" on the y-axis.

An example program feeding the plot_server is included in this repository and named `misc/data_injector.py`.

A short python snippet would look like this
``` python
import requests
data = {
    "tag": "Measurement Name",
    "value": 1234,
    "unit": "W",
    "ts": 1649859909
}
url = "http://localhost:8080"
requests.post(url,json=data)

```

