This repository contains the source code for the Realtimeplot project implemented for the Fritz Haber Institute. This server software can be used together with the Realtimeplot Frontend.
This documentation assumes a GNU+Linux or macOS as host system. Individual commands may differ on Windows hosts.
A current installation of Python 3.9 (GPL-compatible license) is required!
python3 -m venv venv
. venv/bin/activate
- Flask (BSD-3-Clause License)
- Flask-SQLAlchemy (BSD-3-Clause License)
- python-dotenv (BSD-3-Clause License)
- Flask-JWT (MIT License)
- Bleach (Apache License, Version 2.0)
- Flask-CORS (MIT License)
- Archiver Python Frontend (BSD-3-Clause License)
- Eclipse Paho™ MQTT Python Client (Eclipse Public License 2.0 and the Eclipse Distribution License 1.0)
pip install Flask flask-sqlalchemy python-dotenv Flask-JWT bleach flask-cors arvpyf paho-mqtt
Create a .env file in the root directory of this repository!
# General
SECRET_KEY=your_secret_key
FLASK_ENV=development # development or production
FLASK_APP=wsgi.py
FLASK_RUN_HOST=0.0.0.0
# SQLAlchemy
SQLALCHEMY_DATABASE_URI=sqlite:///../test.db # path to database
# Auth
DEFAULT_ADMIN_NAME=admin_login_name
DEFAULT_ADMIN_PASSWORD=admin_login_password
PASSWORD_SALT=password_salt
ACCESS_TOKEN_VALIDITY_TIME=120 # in minutes
# Archive
ARCHIVER_URL=archiver_url
ARCHIVER_TIMEZONE=Europe/Berlin
DEFAULT_ARCHIVER_TIME_PERIOD=7
# MQTT
MQTT_SERVER_URL=mqtt_server_url
MQTT_CHANNEL_PREFIX=mqtt_channel_prefix
# THRESHOLD ALARMS
EMAIL_MQTT_CHANNEL=email_mqtt_channel
THRESHOLD_UNIT=mm
Replace the values (after the =
symbol) with your own values!
- For
General
see: Flask - Builtin Configuration Values - For
SQLAlchemy
see: Flask-SQLAlchemy - Configuration Keys - You can get the URLs (
ARCHIVER_URL
,MQTT_SERVER_URL
) and MQTT channels (MQTT_CHANNEL_PREFIX
,EMAIL_MQTT_CHANNEL
) from the administrators of the corresponding servers.- The MQTT channels are specified in the .env without a leading "/".
flask run
Alternatively, python wsgi.py
can also be used during development.
The server should be accessible at http://127.0.0.1:5000/. However, the configured URL (host + port) is also printed to the command line.
During the first
flask run
, the server will create an admin user with the user_id 0". Username (login_name) and password correspond to the values of DEFAULT_ADMIN_NAME and DEFAULT_ADMIN_PASSWORD defined in the .env file.
Authenticate, create, edit and delete users
Documentation in docs/users_and_authentication.md
Create, get, edit and delete experiments and process variables
Documentation in docs/experiments_and_process_variables.md
Receive experiment data from the archiver
Documentation in docs/experiment_pv_data.md
Set new values for process variables
Documentation in docs/mqtt_publish.md
Subscribe to email alerts for breached process variable thresholds
Documentation in docs/email_threshold_subscription.md
Import and export database entries
Documentation in docs/file_import_export.md
Documentation in docs/cross_endpoint_responses.md
Feedback and contributions are always welcome.
To ensure a consistent code style, please install pre-commit (MIT License).
pip install pre-commit
pre-commit install