Skip to content

About

A lightweight, single-file Python web file browser with uploads, previews, archive browsing, and drag-and-drop file management. No external dependencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

23 Commits

Folders and files

Repository files navigation

Simple HTTP File Browser

English | 한국어 | Español | 日本語

Drag file or folder rows onto a folder in the list or sidebar to move them when writes are enabled. Name clicks keep their existing behavior. Archive contents cannot be moved, and existing items are never overwritten.

A dependency-free, single-file web file browser built entirely with the Python standard library. It provides a responsive, Synology File Station-inspired SPA for browsing and managing files.

Features

  • Browse folders with browser Back navigation; search or sort by name, size, and modification date
  • Expand, collapse, and navigate folders using the sidebar tree
  • Browse ZIP archives as read-only folders without extracting them to disk
  • Download folders as streamed ZIP files with no compression (ZIP_STORED), including subfolders and empty folders
  • Preview browser-supported images, audio, video, plain text, and Markdown with links and tables; download any file
  • Seek through audio and video with HTTP byte-range support; see a clear message when playback fails
  • Upload multiple files using the file picker or drag and drop; append files while uploading, process them sequentially, and preserve each file's destination folder at enqueue time
  • Track each file with its own progress bar, transferred size, and completion status
  • Stream upload data to disk without buffering entire files in memory
  • Create folders, rename items, and recursively delete files and folders
  • Read-only mode by default
  • CLI options and JSON configuration
  • Protection against path traversal and symbolic-link escapes outside the configured root
  • Responsive interface for desktop and mobile browsers
  • Automatic UI language selection based on browser preferences:
    • English: en-US and en-*
    • Spanish: es-ES and es-*
    • Japanese: ja-JP and ja-*
    • Korean: ko-KR and ko-*
    • Unsupported languages fall back to English

Archive browsing

Click an archive name to browse its folders, or use its Download button to download the original archive. Supported formats are .zip, .tar, .tar.gz, .tgz, .tar.bz2, .tbz, .tbz2, .tar.xz, and .txz.

Archive contents support downloads, existing previews, the sidebar tree, and browser history. They are always read-only, including when uploads are enabled. Files inside an archive cannot be uploaded, renamed, deleted, or edited.

Folder Download buttons bundle the selected folder into an uncompressed ZIP, including folders inside an archive. ZIP data streams directly to the browser without creating a temporary ZIP file. Hidden entries follow show_hidden, and filesystem symbolic links are skipped.

Encrypted ZIP members cannot be opened. Unsafe member paths and archive links are excluded. Archives inside another archive are downloadable files, not additional virtual folders. Since 1.7.1, ZIP archive/member/expanded sizes, compression ratio, entry count, path length and depth are unlimited by default. Optional limits can be set through CLI or JSON. One archive operation runs at a time. Bzip2/LZMA/Zstandard ZIP members are refused to avoid CVE-2026-15310 on unpatched Python. Folder ZIP downloads have no default file-count or size limit; optional limits are configurable. RAR and 7z are not supported.

Requirements

  • A currently supported Python release with vendor security updates (tested with Python 3.14.2; update this runtime before production)
  • No third-party Python packages

Quick start

Run the following command from the project directory:

python3 simple_http_file_browser.py --root /path/to/files

Open this address in your browser:

http://localhost:8000

By default, the server listens on all IPv4 interfaces (0.0.0.0) in read-only mode. Open http://SERVER_IP:8000 from another computer. No extra option, password, or TLS proxy is required for direct HTTP access. Without FILE_BROWSER_PASSWORD, access is unauthenticated; use only on trusted networks. Startup warnings describe network exposure, HTTP encryption, and write access. Use --host 127.0.0.1 for local-only access.

Enable write operations

Use --upload to allow uploads, folder creation, renaming, and deletion:

python3 simple_http_file_browser.py \
  --root /path/to/files \
  --port 8080 \
  --upload

Access from another device

Use a TLS reverse proxy or encrypted tunnel. Keep the backend on loopback and prevent direct network access. Set FILE_BROWSER_PASSWORD (at least 16 characters) in your service environment; FILE_BROWSER_USERNAME defaults to admin. Do not commit credentials to JSON or source control. The browser prompts for HTTP Basic credentials.

For example, behind https://files.example.com:

{
  "host": "127.0.0.1",
  "port": 8080,
  "root": "/srv/file-browser-data",
  "public_origin": "https://files.example.com",
  "allowed_hosts": ["files.example.com"],
  "upload": true
}

Preserve the public Host in the proxy, or add the exact backend Host including its port to allowed_hosts. Origin validation uses public_origin; forwarded headers are not automatically trusted. Authentication and HTTPS are recommended for network access, but are not mandatory. The application does not terminate TLS itself: the backend still needs firewall protection.

ZIP browsing limits (1.7.1)

All limits default to 0 (unlimited). Sizes use MiB (1,048,576 bytes). CLI overrides JSON. These settings apply to ZIP member listings, previews and downloads.

JSON key CLI option Limit
max_zip_archive_mb --max-zip-archive-mb Original ZIP size
max_zip_member_mb --max-zip-member-mb Individual member size
max_zip_expanded_mb --max-zip-expanded-mb Total expanded size
max_zip_ratio --max-zip-ratio Per-member compression ratio
max_zip_entries --max-zip-entries Entries including implicit folders
max_zip_path_length --max-zip-path-length Member path character count
max_zip_path_depth --max-zip-path-depth Number of / separators in a member path

To opt into the previous size and ratio limits:

python3 simple_http_file_browser.py --root ./shared-files \
  --max-zip-archive-mb 64 --max-zip-member-mb 64 \
  --max-zip-expanded-mb 256 --max-zip-ratio 100
{
  "max_zip_archive_mb": 64,
  "max_zip_member_mb": 64,
  "max_zip_expanded_mb": 256,
  "max_zip_ratio": 100,
  "max_zip_path_length": 1024,
  "max_zip_path_depth": 32
}

CLI options

ZIP browsing entry counts and folder download file counts / uncompressed sizes are unlimited by default. Set --max-zip-entries 10000, --max-folder-download-files 10000, or --max-folder-download-mb 256 to opt into limits. JSON equivalents are max_zip_entries, max_folder_download_files, and max_folder_download_mb; each defaults to 0 (unlimited). ZIP entries include implicit folders; download counts include files only. CLI overrides JSON. Additional optional ZIP browsing limits are documented below. Unsafe paths and unsupported compression methods are still rejected.

If allowed_hosts / --allowed-host is omitted, the default is * (all valid Host headers). Specify exact hosts to restore Host filtering. The wildcard warning is displayed on startup.

Use --allowed-host "files.example.com:8000" to allow an exact Host header, including its port. Repeat the option for multiple hosts; CLI values replace JSON allowed_hosts. Use --allowed-host "*" to accept every valid Host header (quote * to prevent shell expansion). Wildcard mode disables DNS rebinding protection and prints a warning. Without an explicit public_origin, same-origin HTTP writes are supported for accepted hosts; with public_origin, its origin restriction remains in effect.

--config PATH  JSON configuration file (default: config.json)
--host HOST    IPv4 bind address (default: 0.0.0.0)
--port PORT    Server port (default: 8000)
--root PATH    Top-level accessible folder (default: current directory)
--upload       Enable uploads and file-management operations
--read-only    Disable write operations
--max-upload-mb MB   Upload request limit (default: 0, unlimited)
--max-storage-mb MB  Storage quota (default: 0, unlimited)
--allowed-extension .EXT  Allowed suffix; repeat for multiple (default: unrestricted)
--version      Print the version

Display the complete help output with:

python3 simple_http_file_browser.py --help

Configuration precedence is:

  1. CLI options
  2. JSON configuration file
  3. Program defaults

Sizes of 0 and an extension list of [] mean unrestricted. Existing positive limits in JSON remain active; remove them or set them to 0 to disable them. CLI values override JSON; repeated --allowed-extension values replace the JSON list. To opt into limits:

python3 simple_http_file_browser.py --root /path/to/files --upload \
  --max-upload-mb 64 --max-storage-mb 1024 \
  --allowed-extension .txt --allowed-extension .pdf
{
  "max_upload_mb": 64,
  "max_storage_mb": 1024,
  "allowed_extensions": [".txt", ".pdf"]
}

JSON configuration

Copy the supplied example configuration:

mkdir -p shared-files
cp config.example.json config.json
python3 simple_http_file_browser.py

Example:

{
  "host": "127.0.0.1",
  "port": 8000,
  "root": "./shared-files",
  "upload": false,
  "title": "My File Station",
  "show_hidden": false,
  "max_upload_mb": 0,
  "max_storage_mb": 0,
  "allowed_extensions": [],
  "max_connections": 8,
  "request_timeout": 30,
  "overwrite": false
}
Option Description
host Address on which the server listens
port Server port
root Top-level folder accessible through the browser
upload Whether write operations are enabled
title Title displayed in the web interface
show_hidden Allow listing and direct access to hidden paths (default false)
max_upload_mb Maximum upload size per HTTP request in MB; default 0 (unlimited)
overwrite Whether uploads replace an existing file with the same name
max_storage_mb Root storage quota checked before each upload in MB; default 0 (unlimited)
allowed_extensions Allowed upload/rename suffixes; default [] (unrestricted)
max_connections Maximum active request threads, default 8 (maximum 32)
request_timeout Socket inactivity timeout in seconds, default 30 (maximum 120)
public_origin Exact external HTTP(S) origin, without a trailing slash
allowed_hosts Accepted Host headers including ports; default ["*"] allows all valid hosts

Specify a different configuration file with:

python3 simple_http_file_browser.py --config /path/to/my-config.json

Deletion behavior

  • Files are deleted immediately.
  • Deleting a folder recursively deletes all files and subfolders inside it.
  • Symbolic links inside a deleted folder are removed without following their targets.
  • There is no trash or recovery feature.

Security

HTTP Basic authentication is available through environment variables; HTTPS must be provided by a reverse proxy. Use authentication even on loopback when other local users are not trusted.

  • Writable roots must not contain this script or its configuration file. Keep all application code, credentials and executable directories outside the shared root, and run as an unprivileged account.
  • Hidden paths are denied by default, including direct downloads and archive entries. Enabling show_hidden explicitly allows access.
  • File extensions are unrestricted by default. Set JSON allowed_extensions or repeat CLI --allowed-extension to restrict uploads and file renames. Hidden-path access follows show_hidden.
  • The suffix policy is not content validation or an antivirus. Media can contain concealed bytes. This service does not decode or execute uploaded files on the server; keep external decoders isolated and browsers/players patched. No malware scanner or quarantine pipeline is included.
  • Writes require X-File-Browser-Request: 1; JSON APIs require application/json. Browser Origin and Fetch Metadata are checked. The built-in UI sets this header; API clients must do the same.
  • Uploads run one at a time, with no default upload-size limit or storage quota. Configured limits and a 256 MB free-space reserve are checked. Roots over 10,000 entries refuse further uploads. Quotas cover this process's uploads; external writers and multiple service processes require filesystem quotas. The timeout limits inactivity, not total request duration; use proxy rate and total-duration limits for public deployments.
  • XSS protection uses escaped data attributes and delegated event handlers. Scripts are served separately with a CSP that disallows inline scripts and event attributes.
  • Keep Python and native dependencies patched. ZIP method restrictions mitigate CVE-2026-15310 within this application; they do not patch the installed Python. TAR parsing is disabled to reduce exposure to untrusted archive parsers.
  • Filesystem confinement assumes the shared directory is not concurrently modified by an untrusted local process. Container/mount isolation and filesystem permissions remain necessary against local symlink races.

Run upload-limit regression tests with python3 -m unittest test_upload_limits -v. The tests use only the Python standard library.

Stopping the server

Press Ctrl+C in the terminal running the server.

ZIP browsing regression tests: python3 -m unittest test_zip_browsing -v.

About

A lightweight, single-file Python web file browser with uploads, previews, archive browsing, and drag-and-drop file management. No external dependencies.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages