Simple number counting service with HTTP API
- Python 3.10
- SQLite
$ pip install poetry
$ poetry install
$ ln -s ../../hooks/pre-commit .git/hooks
$ mkdir db
$ python app.py
$ docker build . -t counter
$ export COUNTER_DATABASE_PATH=/your/database/path
$ docker run -p 8000:8000 --rm -v "$COUNTER_DATABASE_PATH:/app/db" counter
You can count number with memo.
$ curl -X POST localhost:8000/count/ --data '{"memo": "initial"}'
{"success":true,"data":{"number":1,"memo":"initial"}}
Or you can without memo too.
$ curl -X POST localhost:8000/count/
{"success":true,"data":{"number":2,"memo":null}}
To set start number, you sholud manually update database's value.
$ sqlite db/counter.db
SQLite version 3.7.17 2013-05-20 00:56:22
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite> UPDATE SQLITE_SEQUENCE SET seq = 977 WHERE name = 'cnt';
sqlite>
Then it counts from the number after the number you choose.
$ curl -X POST localhost:8000/count/
{"success":true,"data":{"number":978,"memo":null}}