Files
sensors/README.md
2025-12-09 09:53:55 +01:00

1.9 KiB

sensordata

Usage

The only two files needed to be running are the web server in web.py and the MQTT client in mqtt_client.py.

The web server launches into built-in Flask debug mode, in a production environment it is recommended to launch the file with a WSGI provider like gunicorn.

The MQTT Client is a FastAPI App and can be launched natively or with FastAPI provided by your system.

The script sql_startup.sql contains commands to set up the layout of the database which the program expects.

TODO: probably delete the "extra commands" and segment the example data out

Dependencies

This repository does not include two external dependencies, namely the SQL server and MQTT broker. The tested choices for those dependencies are MariaDB and Mosquitto, but alternatives may work as well

Internal dependencies are contained as standard within requirements.txt

Extra files

There are three ignored files contained in the implementation:

  • db_creds.csv which contains credentials for connecting to the database, in the format: username,password,hostname,port,database name
  • session_key.txt and pwd_key.txt are both random keys used for session cookie signing and key encryption respectively

Customization

The file static_text.toml provides several strings of static text throughout the website which may be easily customized. Do note that the strings are parsed direcly as HTML and thus further formatting and styling is possible this way. However caution should be taken with inserting data that may be parsed as HTML.

The SQL startup script generates the user called nouser with the ID 1, the ID may not be customized however the username may be freely changed.

Unit files

This repository does not provide unit files, however it is recommended to launch both web.py and mqtt_client.py after the SQL and MQTT services