Python Flask Webserver Template
Python3 website template including git actions
Requirements
- UV
Development
- Install project requirements
uv sync
- Run the dev server
uv run python3 server.py
- Alternatively use the virtual environment
source .venv/bin/activate
You can exit the environment with deactivate
For best development setup, you should install the git hook for pre-commit
uv run pre-commit install
Production
Run using the main.py file
python3 main.py
When running in Docker, a cron job is configured to call the pool overview endpoint every 5 minutes so stats snapshots continue collecting even without external traffic.
- Default cron target:
http://127.0.0.1:5000/api/v1/pool/overview - Override with:
STATS_CRON_URL
Pool Tracking
The server now records pool stats over time and stores them in SQLite.
pool hashratesnapshotsactive worker countsnapshotstop mining addressesper snapshot interval
Environment variables:
STATS_DB_PATH(default:data/pool_stats.db)STATS_SAMPLE_INTERVAL_SECONDS(default:60, minimum:10)
Tracking data is collected when pool API routes are called and is bucketed by sample interval.
Discord Alerts
The pool overview route can send Discord webhook alerts for key events:
- new block found
- block matured
- payouts sent
Alerts are sent as Discord embeds with clickable explorer links for blocks and transactions when identifiers are available.
Environment variable:
DISCORD_WEBHOOK_URL(default: disabled)EXPLORER_BASE_URL(default:https://explorer.fistbump.org)
Notes:
- Alerts are deduplicated using persistent state in the same SQLite database.
- On first run with a webhook configured, existing chain/payout state is bootstrapped and no historical alert burst is sent.
History endpoint:
GET /api/v1/pool/history?hours=24&limit=1000
Query parameters:
hours: lookback window in hours (1 to 720)limit: max number of snapshots returned (10 to 5000)
Response includes:
hashrate_series: pool hashrate over timeworker_series: worker count over timelatest_top_addresses: top addresses in latest snapshottop_addresses_over_period: aggregated top addresses over window