Skip to content

Hexanol777/LocalShare

Repository files navigation

LocalShare

A self-hosted LAN media server built for home and small-office networks. Run it on any machine, point your phone or laptop to http://share.local, and instantly browse, stream, and upload files — no cloud, no accounts, no configuration.


How it works

LocalShare runs a lightweight Flask server on your host machine and exposes itself on the local network using mDNS (Zeroconf), so every device on the same Wi-Fi can reach it by name rather than memorising an IP address. The host machine is automatically treated as admin; remote devices join as guests and can request elevated access via a password.


Features

File browser

Browse the host filesystem (or any directory you point the server at) through a folder-based interface. Navigation is breadcrumb-tracked, and folders containing only images automatically offer a dedicated reader view.

Uploading

Drag and drop files or entire folder trees directly into the directory you are currently browsing. Upload progress is shown in real time with transfer speed and estimated time remaining. Upload access is restricted to admin users.

Streaming

Native browser formats (MP4, WebM, MP3, FLAC, AAC, and others) open in an inline player. MPEG-TS streams are handled via mpegts.js. All streams support byte-range requests for accurate seeking.

Watch Together

Multiple users on the same network can open a shared watch session for any streamable file. Playback is synchronised in real time via WebSocket — play, pause, and seek events are broadcast to all participants. Latency between clients is measured and displayed.

LAN Chat

A lightweight real-time chat room available to everyone on the network. No accounts required.

Image Reader

Folders containing image files (manga, comics, scans) can be opened in a dedicated full-screen reader with vertical scroll and single-page horizontal modes, keyboard navigation, and per-folder mode persistence.

Admin System

The host machine (localhost) is elevated to admin automatically with no password required. Remote devices can authenticate at /login using a master password. Admin sessions persist for 30 days via a signed cookie. Admins can upload, delete, and rename files inline. Guests can browse, stream, download, and chat.

mDNS Discovery

The server registers itself as http://share.local on the local subnet using Zeroconf, so no one needs to look up or remember an IP address.

Thumbnail Generation

Image files display previews generated by Pillow. Video thumbnails are extracted via ffmpeg if available, with results cached to avoid redundant processing.


Requirements

Python 3.10+
Flask
Flask-SocketIO
Flask-SQLAlchemy
APScheduler
Pillow
zeroconf
werkzeug

Install all dependencies:

pip install -r requirements.txt

ffmpeg is optional but required for video thumbnail generation.


Running

Share the default uploads/ folder:

python app.py

Share a specific directory:

python app.py "C:\Users\you\Videos"
python app.py /home/you/media

The server starts on port 80 and is reachable at http://share.local from any device on the same network. The terminal will print a warning if the default admin password has not been changed.


Configuration

Both values are read from environment variables at startup.

Variable Default Description
SECRET_KEY Auto-generated Signs session cookies. Set a persistent value to survive restarts.
ADMIN_PASSWORD admin123 Master password for remote admin login. Change this.

Windows (PowerShell):

$env:ADMIN_PASSWORD = "yourpassword"
$env:SECRET_KEY = "a-long-random-string"
python app.py

Linux / macOS:

ADMIN_PASSWORD=yourpassword SECRET_KEY=a-long-random-string python app.py

Access model

Context Role Capabilities
Host machine (localhost) Admin Full access, no password required
LAN device, authenticated Admin Full access after /login
LAN device, unauthenticated Guest Browse, stream, download, chat

Admin sessions last 30 days. Log out at any time via the header button.


File cleanup

When running in default mode (no directory argument), files older than 24 hours are removed automatically on an hourly schedule. Chat messages follow the same policy. When a custom directory is passed as an argument, no automatic deletion occurs — the server treats the directory as read/write storage only.


Stack

Layer Technology
Backend Python, Flask, Flask-SocketIO
Database SQLite via Flask-SQLAlchemy
Real-time WebSocket (threading mode)
Network discovery Zeroconf / mDNS
Frontend Vanilla JS, Chart.js (watch latency)
Thumbnails Pillow, ffmpeg

Technical Architecture

LocalShare utilizes an event-driven synchronization engine to keep media playback perfectly aligned across all local network clients. the exact lifecycle of client actions, state transitions, rate-limiting rules, and WebSocket broadcasts can be seen in the sequence diagram below:

LocalShare Sequence Diagram

About

LocalShare is a lightweight self-hosted media server that is made with simplicity and performance in mind.

Topics

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages