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.12.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.12.0-py3-none-any.whl (16.8 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: cashier_server-0.12.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.12.0.tar.gz
Algorithm Hash digest
SHA256 d98080331d8210a3c35202f353b7aafa30b51ce3e3cb823568136886abfc5bb2
MD5 e9e29f1ac9fc3b374f47f511b4dc614f
BLAKE2b-256 0f3cbc9f1267c1cfa09cb8e054df5f17e8ab3ffa50ce2d4fe88893c2146199ce

See more details on using hashes here.

File details

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

File metadata

  • Download URL: cashier_server-0.12.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.12.0-py3-none-any.whl
Algorithm Hash digest
SHA256 6fea286fc3a250877d9a01a297fbc68b70217ef789cb0c6f2cff22956a1cf338
MD5 5698ae2e9a38de6fe1e8909e2f11bcf0
BLAKE2b-256 b6e2e554e0334a60d31cc420ba3851333c9bcd647cf93e598e13e00dc3b5b043

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