boyska 0d31b32429 http api to just check authentication status 1 year ago
..
pages a82b082a2f prenota: vagamente usabile 2 years ago
static dcea0ce37d reconnect automatically 1 year ago
.gitignore 82fcc75429 configuration sample 1 year ago
Dockerfile 07315e0a6b move to SSL encryption 2 years ago
README.md 82fcc75429 configuration sample 1 year ago
docker-compose.yaml 7da91b8aae counter is persisted 2 years ago
pizzicore.env.sample 1b78cd9fee password is a setting 1 year ago
pizzicore.py 0d31b32429 http api to just check authentication status 1 year ago
requirements.txt 7c9bd6a700 websocket works 2 years ago

README.md

Componente centrale del sistema pizzicaroli. tiene i conti. espone HTTP e WebSocket.

Alcune API richiedono autenticazione.

Il docker incluso è solo per comodità di sviluppo, non è strettamente necessario.

Concetti

Contatori multipli

Il codice gestisce più di un contatore, per generalità, anche se non è chiaro se questa cosa ci servirà. I contatori partono da 0, quindi in genere useremo sempre 0.

Storage

Il sistema ha un suo storage, in modo che al riavvio i contatori ripartano da dove erano.

HTTP API

GET /counter/0 ti dà il valore

POST /counter/0/increment incrementa, ma richiede basic-auth

WebSocket API

/ws/counter/0 ti dà il valore e ti riaggiorna ogni volta che questo cambia. Ignora ogni messaggio in ingresso.

Lanciare

Docker compose

docker-compose up

Debian Bullseye

Just install a few packages from the standard repositories, and you're set. No pip, virtualenv, …

apt install python3-fastapi python3-dotenv uvicorn
env QUEUES_NUMBER=2 uvicorn pizzicore:app --reload --port 8000 --host 0.0.0.0

In the snippet above, you can see how to set variables on the commandline. See pizzicore.env.sample for a list of settings.

You can also create a pizzicore.env file (named exactly like that) as a configuration method.

Environment variables take precedence over configuration files.

TODO

  • configurazione
  • esempi d'uso