2021-06-19 11:05:35 +02:00
|
|
|
# IOT Data
|
|
|
|
|
|
|
|
Just a tiny service for posting small datasets to a server which can get fetched by other services afterwards.
|
|
|
|
|
|
|
|
It just keeps the data in RAM so it is definetely not for big stuff and log term storages.
|
|
|
|
|
|
|
|
## Usage
|
|
|
|
|
|
|
|
Read data:
|
|
|
|
```
|
|
|
|
curl http://iot-data.clerie.de/data/sensor1/
|
|
|
|
```
|
|
|
|
|
|
|
|
Write data:
|
|
|
|
```
|
|
|
|
curl -X POST -d 'hello world!'' -H 'Content-Type: text/plain' http://iot-data.clerie.de/ingress/asdf1234/
|
|
|
|
```
|
|
|
|
|
|
|
|
Content type is considered too:
|
|
|
|
```
|
|
|
|
curl -X POST -d '{"key": "value"}' -H 'Content-Type: application/json' http://iot-data.clerie.de/ingress/asdf1234/
|
|
|
|
```
|
|
|
|
|
2021-06-20 12:19:35 +02:00
|
|
|
Check for the last data input with the `Last-Modified` header.
|
|
|
|
|
2021-06-19 11:05:35 +02:00
|
|
|
## Deployment
|
|
|
|
Init codebase
|
|
|
|
```
|
|
|
|
git clone https://github.com/clerie/iot-data.git
|
|
|
|
cd iot-data/
|
|
|
|
virtualenv -p python3 ENV
|
|
|
|
cd ..
|
|
|
|
```
|
|
|
|
|
|
|
|
Create `config.json` with the following contents and edit values for your needs:
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
"sensor1": {
|
|
|
|
"key": "asdf1234"
|
|
|
|
},
|
|
|
|
"sensor2": {
|
2021-06-20 12:19:35 +02:00
|
|
|
"key": "supersecret",
|
|
|
|
"delete-after": 60
|
2021-06-19 11:05:35 +02:00
|
|
|
},
|
|
|
|
}
|
|
|
|
|
|
|
|
```
|
|
|
|
|
2021-06-20 12:19:35 +02:00
|
|
|
`delete-after`: Specifies the seconds after which the data gets discarded and no data is returned.
|
|
|
|
|
2021-06-19 11:05:35 +02:00
|
|
|
Starten und updaten lässt sich die Flask-App folgendermaßen:
|
|
|
|
```
|
|
|
|
cd iot-data/
|
|
|
|
git pull
|
|
|
|
source ENV/bin/activate
|
|
|
|
pip install -r requirements.txt
|
|
|
|
IOT_DATA_CONFIG=/path/to/config.json gunicorn iot_data:app
|
|
|
|
deactivate
|
|
|
|
```
|