47 lines
1.3 KiB
Markdown
47 lines
1.3 KiB
Markdown
# API Service
|
|
|
|
Minimal Flask HTTP API that reads from the `fr24` PostgreSQL schema and exposes data for the noisemap UI.
|
|
|
|
## Endpoints
|
|
|
|
| Method | Path | Description |
|
|
|---|---|---|
|
|
| GET | `/health` | API + DB liveness check |
|
|
| GET | `/dashboard/status` | Ingest pipeline stats (captures, packets, processing cursor, aircraft, flights) |
|
|
| GET | `/viewer/config` | Static system config for the map viewer |
|
|
| GET | `/captures` | List capture sessions (`?limit=50`) |
|
|
| GET | `/aircraft` | List aircraft (`?limit=100`) |
|
|
| GET | `/flights` | List flights (`?limit=100&status=active`) |
|
|
|
|
## Dependencies
|
|
|
|
- `flask` — HTTP server
|
|
- `psycopg2-binary` — PostgreSQL driver
|
|
|
|
## Environment variables
|
|
|
|
| Variable | Default | Description |
|
|
|---|---|---|
|
|
| `POSTGRES_HOST` | required | DB host |
|
|
| `POSTGRES_PORT` | `5432` | DB port |
|
|
| `POSTGRES_DB` | required | DB name |
|
|
| `POSTGRES_USER` | required | DB user |
|
|
| `POSTGRES_PASSWORD` | required | DB password |
|
|
| `API_PORT` | `8080` | Port to listen on |
|
|
|
|
## Run locally
|
|
|
|
```bash
|
|
pip install -r requirements.txt
|
|
export POSTGRES_HOST=localhost POSTGRES_DB=fr24 POSTGRES_USER=fr24 POSTGRES_PASSWORD=change-me
|
|
python main.py
|
|
# → http://localhost:8080/health
|
|
```
|
|
|
|
## Build & run via Docker
|
|
|
|
```bash
|
|
docker build -t fr24-api .
|
|
docker run -p 8080:8080 --env-file ../../compose/.env fr24-api
|
|
```
|