Kiezbox Messages App to send emergency calls
Project description
Kiezbox Notruf-App
Tested with Python 3.11
Architecture
One main driver was the will to have something minimalistic while still modern. A first try to have a separate frontend using react and dynamic routes has proven to be problematic as installing node modules and having a running node instance on IoT devices isn't great. Thus we have server-side template rendering for the frontend. In these templates we use HTMX to handle the interactivity.
The backend is fastapi, using sqlmodel to unite sqlalchemy and pydantic. FastAPI is serving some static files as well as the Jinja2 templates using uvicorn. We use a HTML form to send the emergency calls. We use server-sent events (SSE) to trigger reloads on the inbox.
Backend Installation guide
Set your virtual environment
The following steps are not required but recommended. This will allow you to install packages in your isolated virtual environment instead of globally, reducing the risk of breaking system tools or other projects.
- Install pyenv and the pyenv-virtualenv plugin.
- Download the appropriate Python version with
pyenv install 3.11
in the command line. - Create a virtual environment with the appropriate Python version and name for your environment, for example
pyenv virtualenv 3.11 kiezbox
- Activate the environment with
pyenv activate kiezbox
Run the App
- Install the required libraries with the command line
pip install -r requirements.txt
- Run the server with the command line
uvicorn main:app --reload
- Your terminal should show something like:
INFO: Uvicorn running on http://127.0.0.1:8000 (Press CTRL+C to quit)
Open this URL with the /docs
suffix in your server to access the Swagger documentation of the API. For this example: `http://127.0.0.1:8000/docs
Update the model
If you want to run an updated version of the API which introduces changes in the database models (for example, a new field), you will have to wipe the database clean first. To do this, simply delete the backend.db
file.
Frontend
On the JS side, the interactivity is handled by HTMX, which is shipped locally as we are in a case where phones have no internet connectivity. Currently v1.9.10 is included. See https://github.com/bigskysoftware/htmx/releases.
We have a second JS file which is the SSE extension for HTMX. You can get the latest version from https://github.com/bigskysoftware/htmx/tree/master/dist/ext.
The frontend is simple Jinja2 server-rendered templates styled with TailwindCSS.
Run npm install
.
To watch CSS updates, you may run npm run dev
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for kiezbox_messages-0.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9627a95eb1359b7a98b18fc0a3720672537c64bd44474716d2da0d54b77f3ad6 |
|
MD5 | 185bff6c4dc9ed94fcb477aecad28d2d |
|
BLAKE2b-256 | f4c0268f00cacbb61101063d20d216f805b438e237ab9ca39cb29e2f7196efad |