Skip to main content

runlight

Runlight is privacy friendly web analytics that runs inside your own Python app. It counts visitors without cookies and without storing anyone’s IP address. The numbers stay in your database, and the dashboard is served from your domain at /runlight.

This package is the Python version of Runlight. It works in Django, Flask, FastAPI, or any WSGI or ASGI app on Python 3.11 or later, and it can also run on its own domain as a standalone server. It answers every request the way the TypeScript library does and uses the same tables, so either one can read the other’s database.

Get started

Install it with pip.

pip install runlight

SQLite comes with Python. For Postgres, install runlight[postgres], and for MySQL or MariaDB, runlight[mysql]. On Windows, add the tzdata extra for time zones.

Create one instance for your app.

from runlight import Runlight
from runlight.store import Stores

rl = Runlight(
    store=Stores.sqlite("data/runlight.db"),
    site={"name": "example.com", "hostnames": ["example.com"], "timezone": "Europe/London"},
)

Runlight reads the visitor's address from X-Forwarded-For and similar headers only when the request comes from this computer or a private network, where proxies and load balancers connect from, so a visitor who reaches your app straight from the internet cannot pick their own address. Behind a CDN that connects from public addresses, such as Cloudflare in front of your server, add trust_proxy="cf-connecting-ip" (the header it sets) or trust_proxy=True. Runlight logs a warning once when a public address sends forwarding headers that the default did not believe. trust_proxy=False never reads them.

Put it in front of your app. In Flask that is one line.

import runlight.flask

runlight.flask.init_app(app, rl)

Add the script to every page, just before </head>.

<script defer src="/runlight/s.js"></script>

Set RUNLIGHT_TOKEN to a long random string, then open /runlight/?token= followed by that string to sign in.

A token passed to rl.routes() works the same way. None counts as not given, so os.environ.get() of a variable that is not set falls back to RUNLIGHT_TOKEN and never opens the dashboard. To leave it open on purpose, behind your own sign-in, pass token=runlight.OPEN.

The Python guide has the code for Django, FastAPI, and plain WSGI or ASGI apps, the Postgres, MySQL, and MariaDB stores, the scheduled check, and the standalone server.

License

Runlight is MIT licensed.

Metadata

Release files for runlight 0.4.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for runlight 0.4.0
File Size Uploaded Provenance Actions
runlight-0.4.0.tar.gz 571.6 kB Without provenance Details for runlight-0.4.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for runlight 0.4.0
File Interpreter ABI Platform Actions
runlight-0.4.0-py3-none-any.whl Python 3 none any Details for runlight-0.4.0-py3-none-any.whl

Total release size: 1.2 MB

Release files / runlight-0.4.0.tar.gz

Download URL runlight-0.4.0.tar.gz
Size 571.6 kB
Tags Source
SHA-256 checksum
How to use checksums
9faa6b572945ef92ba7c109dcc53114d0160506bfdff2a49d0b322df0cfea210
BLAKE2b-256 checksum
How to use checksums
6dbfdc01eef34c184a2d029334d120a246c5aa237554acb2da0ba32ddf4b9fb7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / runlight-0.4.0-py3-none-any.whl

Download URL runlight-0.4.0-py3-none-any.whl
Size 617.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
908377de9a0bed0d5c32290b56becc6482ad5dec2c37a115e2a1b08373ca6d9e
BLAKE2b-256 checksum
How to use checksums
623230a98afaf49c97b4390602a77ca42566a9cc223f7ccb1b788114295190e9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.7 {"installer":{"name":"uv","version":"0.13.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"26.04","id":"resolute","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Security for runlight 0.4.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page