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"},
)

If nothing sits in front of your app (no load balancer, CDN, or reverse proxy), add trust_proxy=False, so a visitor cannot pick their own address with an X-Forwarded-For header. Runlight logs a warning once when it sees requests arrive that way with the default left on.

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.1.7

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.1.7
File Size Uploaded
runlight-0.1.7.tar.gz 534.5 kB Details

Built distribution (wheel)

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

Total release size: 1.1 MB

Release files / runlight-0.1.7.tar.gz

Download URL runlight-0.1.7.tar.gz
Size 534.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7f6e84cee79ba555fb0775fc64e02e0064517bc52d1b07447cb562909f7e3b88
BLAKE2b-256 checksum
How to use checksums
fa36b5bde7feccff3be8a10bd9b6c6fb6b531c1a7c3b54ec21aaf0f6ee29fce2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

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

Download URL runlight-0.1.7-py3-none-any.whl
Size 579.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
92f56698633eb081b6f816656b985e2d2cea8944c5e18ffe4c0f84d6aad9c6b5
BLAKE2b-256 checksum
How to use checksums
dd55aefdb9210fdcd0d02a1e11a5b8f98f025181b9b8199306044795e37812c8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.13.1 {"installer":{"name":"uv","version":"0.13.1","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

0.1.8

2 release files

This release

0.1.7 This release

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

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