DEV Community

RK Riad Khan
RK Riad Khan

Posted on

Share Files Over LAN with a QR Code - a tiny Python CLI

If you've ever needed to move a file from your computer to your phone
(or to a colleague on the same Wi-Fi), you know the usual options are
all slightly annoying: email, cloud drives, USB cables, chat apps that
compress or require accounts.

qrtransfer solves it with one command and one scan: it serves files
over HTTP on your LAN and prints a QR code in the terminal. Scan it
with your phone's camera and the download starts.

Usage

# Share a file
qrtransfer myphoto.jpg

# Share a whole folder (auto-zipped)
qrtransfer builds/

# Share a text snippet
qrtransfer --text "hello world"

# Receive files from your phone
qrtransfer receive
Enter fullscreen mode Exit fullscreen mode

Nice defaults, honest limits

  • Stops after the first successful download by default; --keep-alive or --max-downloads N changes that.
  • Unguessable tokens (secrets.token_urlsafe) so links aren't guessable.
  • Password via ?passed=SECRET or X-Password header; expiry returns HTTP 410.
  • --tls for self-signed HTTPS, --ipv6 supported, --clipboard copies the URL.

How it's built

  • Python 3.9+, stdlib http.server + ThreadingHTTPServer.
  • psutil for interface/IP detection, platformdirs for config paths, qrcode-terminal for the QR output.
  • Streaming multipart parser for receive mode - large uploads never buffer fully in memory, and filenames are sanitized against path traversal.
  • One mutable Session dataclass drives everything; no module globals.

Testing & CI

The repo ships a pytest suite (unit + in-process integration + CLI
end-to-end) run across Ubuntu, Windows, and macOS on Python 3.9/3.11/
3.13, plus ruff linting and pyright type-checking. It's also packaged
as a Docker image (ghcr.io/rkriad585/qrtransfer) and published on
PyPI as qrtransfer-lite.

Install

pip install qrtransfer-lite
# extras: [clipboard], [tls]
Enter fullscreen mode Exit fullscreen mode

Or from source:

git clone https://github.com/rkriad585/qrtransfer
cd qrtransfer && pip install -e ".[dev]"
Enter fullscreen mode Exit fullscreen mode

It's MIT licensed. Feedback and PRs welcome.

Links:

Top comments (0)