Skip to main content

Cashier synchronization server in Python

Project description

cashier-server-python

Cashier synchronization server, in Python

Ledger-cli REST server for Cashier PWA, implemented in Python with FastAPI.

Cashier Server acts as a mediator between Cashier PWA and Ledger CLI, forwarding queries to Ledger and the results to Cashier. Used for synchronizing the ledger data in Cashier.

This is a Python implementation of the Cashier Server using FastAPI.

Installation

  1. Install uv
  2. Install uv tool install cashier-server

Configure Backend

To use Beancount as a back-end, set the BEANCOUNT_FILE environment variable.

The easiest way is by creating an .env file containing this variable, which should point to your Beancount book. Otherwise, Cashier Server will use Ledger as the backend.

Configure Certificates

Create a self-signed certificate with OpenSSL.

Add CASHIER_SSL_KEY and CASHIER_SSL_CERT paths to .env file, pointing to generated key.pem and cert.pem.

Android

On Android, import the cert.pem. Usually Settings -> Security -> Install certificate -> CA Certificate.

Then, open the Cashier Server URL in the browser and accept the self-signed certificate.

Run

Execute cashier-server-py script provided by the cashier-server package.

The server runs on 0.0.0.0:3000, matching the Rust implementation.

API Endpoints

  • / - Execute a ledger command
  • /hello - Return a base64-encoded image
  • /ping - Simple health check
  • /reload - Reload the Beancout data
  • /shutdown - Request server shutdown
  • /infrastructure/config - Return the Beancount config file content
  • /infrastructure/accounts - Return the Beancount accounts file content
  • /infrastructure/commodities - Return the Beancount commodities file content

CORS is enabled for all origins, similar to the Rust implementation.

Development

VSCode recommended. Run the run.cmd script to start the server. Or run from VSCode to debug.

Debug

Make sure that Beancount is configured and can be called from the current directory. Then run:

run.cmd
# or
uv run python app.py
# Or uvicorn directly:
uvicorn app:app --host 0.0.0.0 --port 3000

Notes on the Implementation

  • Logging is configured to output to the console.
  • For the /hello endpoint, you would need to provide an actual image file named "hello.png" in the same directory as the app.py file.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cashier_server-0.13.0.tar.gz (34.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

cashier_server-0.13.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

Details for the file cashier_server-0.13.0.tar.gz.

File metadata

  • Download URL: cashier_server-0.13.0.tar.gz
  • Upload date:
  • Size: 34.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cashier_server-0.13.0.tar.gz
Algorithm Hash digest
SHA256 25d640e68071f3c6ee4d221981baedfc3011a8fea881925bedcc3f130b1deacc
MD5 8bff040c5f5b4f5ba50236d2838e1fee
BLAKE2b-256 4fe76a9d627328b636597348f1627683b490940f5f265d64965ce50e88863074

See more details on using hashes here.

File details

Details for the file cashier_server-0.13.0-py3-none-any.whl.

File metadata

  • Download URL: cashier_server-0.13.0-py3-none-any.whl
  • Upload date:
  • Size: 16.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for cashier_server-0.13.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3634ddae57f8be68ed86872c4c96c37899d467bc63f1df944d79208ed14f185f
MD5 db4a6b17b582cc348e135c9067fae4b3
BLAKE2b-256 3a958646301c604eb069d252a6c45d03127d509379ee39a8405a1921ade1ecb0

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page