Metadata-Version: 2.4
Name: LabFlask
Version: 0.0.1
Author-email: Christian Grosz <christian.grosz@centerofgravity.at>
License-Expression: AGPL-3.0-only
Project-URL: repository, https://codeberg.org/Boeingflieger/LabFlask
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE.md
Requires-Dist: Flask>=3.1.2
Requires-Dist: Flask-SocketIO>=5.5.1
Requires-Dist: eventlet>=0.40.3
Dynamic: license-file

---
gitea: none
include_toc: true
---
# LabFlask

This Flask based web server connects to your (HP) lab equipment via linux-gpib,
allowing you to remote control it from any modern web browser.

This is a very first version just to get things moving, and it's highly limited.

- To the HP 3478A
- with an harcoded adress
- using the _--no-websockets_ option
- and not stable

<img src="docs/LabFlask.svg">

## Compatibility & OS Support

This software was developed and tested exclusively under Linux.

To access instruments connected to a GPIB card the latest [Linux GPIB Package](https://linux-gpib.sourceforge.io/) [4.3.7](https://sourceforge.net/projects/linux-gpib/files/linux-gpib%20for%203.x.x%20and%202.6.x%20kernels/4.3.7/) is needed.

## Installation

For the latest version please download the source code or clone the repository. Generate the distribution archives using [`build`](https://build.pypa.io/en/latest/). These archives (`.whl`,`.tar.gz` or `.zip`) can be installed by [`pip`](https://packaging.python.org/en/latest/key_projects/#pip).

```bash
cd LabFlask                                                                # Where the 'pyproject.toml' is located.
python3.12 -m build                                                        # Generate the distribution archives.
sudo pip install --force-reinstall dist/labflask-0.0.1-py3-none-any.whl    # Install the package.
sudo pip uninstall labflask                                                # Remove the package.
```
Or install the published package from PyPI.

```bash
sudo pip install -i https://pypi.org/simple/ labflask
```

> [!NOTE]
> A global installation is recommended since this application will likely be deployed as a systemd service.

## Setup

> [!CAUTION]
> **Unrestricted Application Access:**
> This Flask application is currently running with NO data validation or entry
> restrictions. All payloads are forwarded unchecked as commands over GPIB.
>
> 1. DO NOT expose this server to the public internet under any circumstances.
> 2. Ensure the host is strictly bound to localhost (e.g., host='127.0.0.1').
> 3. Restrict network access via firewalls if local network sharing is required.
>
> Exposing this application publicly will vulnerable your lab equipment to attacks.

This application requires external dependencies and files beyond standard Python packages. The _LabFlask-setup_ script will guide you through most of this configuration process.

```bash
sudo /usr/local/bin/LabFlask-setup
```

## Command reference

```text
usage: LabFlasked [-h] [-c CONFIG] [-H HOST] [-p PORT] [-w | --websockets | --no-websockets] [-D] [-v]

options:
  -h, --help            show this help message and exit
  -c CONFIG, --config CONFIG
                        path to config file (default: ['~/.config/LabFlask/settings.ini', '/etc/LabFlask/settings.ini'])
  -H HOST, --host HOST  network interfaces the server is listen too (default: 127.0.0.1)
  -p PORT, --port PORT  port the server is listen too (default: 5002)
  -w, --websockets, --no-websockets
                        force use of websockets instead of polling (default: False)
  -D, --debug           set debug mode for Socket.IO (default: False)
  -v, --verbose         set verbose mode (default: 0)
```
