Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

6 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Portal Files

Python 3.11 TypeScript

A local file server with a web-based UI for browsing, uploading, editing, and downloading files. Specifically designed for legacy browsers including Safari on iPad 4 (iOS 10.3.3) and Internet Explorer 11.

Local file explorer

Features

  • ๐Ÿ“‚ File Browser โ€” Navigate directories with breadcrumb UI
  • ๐Ÿ“ฅ Download โ€” Direct file downloads
  • ๐Ÿ“ค Upload โ€” Multi-file upload with progress tracking
  • โœ๏ธ Text Editor โ€” Create and edit text files (.txt, .md, .js, .php, etc.)
  • ๐Ÿ‘๏ธ File Viewer โ€” Read-only viewer with markdown preview for .md files
  • ๐Ÿ“ Markdown Preview โ€” Live HTML preview for markdown files
  • ๐Ÿ—‘๏ธ Delete โ€” Remove files and empty directories
  • ๐Ÿ“ Create Folders โ€” New directory creation
  • โ–ถ๏ธ VLC Integration โ€” Open media files in VLC via custom URL scheme
  • ๐ŸŽฎ Tetris โ€” Built-in game (because why not?)
  • ๐Ÿ› Debug Panel โ€” Remote error inspection via on-screen console
  • ๐Ÿ“ฑ Touch-Optimized โ€” Tablet and mobile-friendly interface
  • ๐Ÿ”’ Security โ€” Path traversal protection with safe_join and secure_filename

Why This Project?

Several file browser web apps exist (filebrowser/filebrowser, mickael-kerjean/filestash), but none target legacy browsers like Safari on iOS 10.3.3 or IE11. This project compiles TypeScript to ES5, uses XMLHttpRequest instead of fetch, and avoids modern CSS features (no Grid, prefixed Flexbox) to ensure compatibility with older devices.

Originally created to solve iPad 4 โ†’ Mac file transfer issues.

Prerequisites

Setup

1. Python Environment

# Create and activate the conda environment
conda env create -f environment.yml
conda activate portal_files

2. Frontend Build

# Install pnpm if you don't have it
npm install -g pnpm

# Install Node.js dependencies
pnpm install

# Build the frontend (TypeScript โ†’ ES5 JavaScript)
pnpm run build

3. Run the Server

# Serve files from the ./files directory (default)
python run.py

# Serve files from a specific directory
python run.py --root /path/to/files

# Custom host and port
python run.py --host 0.0.0.0 --port 8081

Open your browser and navigate to http://localhost:8081.

Development

Frontend Development

# Watch mode โ€” automatically rebuilds on changes
pnpm run watch

# Lint TypeScript code
pnpm run lint

# Fix lint issues
pnpm run lint:fix

# Format code with Prettier
pnpm run format

# Check formatting
pnpm run format:check

Python Linting

# Lint Python code with ruff
ruff check server/ run.py

# Format Python code
ruff format server/ run.py

Configuration

The server can be configured via environment variables or CLI arguments:

Variable CLI Flag Default Description
PORTAL_FILES_ROOT --root ./files Root directory to serve
PORTAL_HOST --host 0.0.0.0 Host to bind to
PORTAL_PORT --port 8081 Port to listen on
PORTAL_DEBUG --debug true Enable debug mode

Architecture

Backend (Python / Flask)

  • run.py โ€” Entry point with CLI argument parsing
  • server/app.py โ€” Flask application factory
  • server/config.py โ€” Configuration management
  • server/routes/api.py โ€” File listing and download API
  • server/routes/logging.py โ€” Client-side error log receiver

Frontend (TypeScript โ†’ ES5)

  • src/main.ts โ€” Application entry point
  • src/api.ts โ€” XHR-based API client
  • src/navigation.ts โ€” Hash-based client-side routing
  • src/ui.ts โ€” Main UI controller
  • src/events.ts โ€” Event bus (pub/sub) to break circular dependencies
  • src/breadcrumb.ts โ€” Breadcrumb navigation component
  • src/file-list.ts โ€” File listing component with view/edit/delete actions
  • src/uploader.ts โ€” Multi-file upload with progress tracking
  • src/editor.ts โ€” Text file editor with markdown preview
  • src/viewer.ts โ€” Read-only file viewer with markdown preview
  • src/newfolder.ts โ€” New directory creation dialog
  • src/markdown.ts โ€” Markdown-to-HTML parser
  • src/tetris.ts โ€” Self-contained Tetris game
  • src/vlc.ts โ€” VLC URL scheme integration
  • src/error-logger.ts โ€” Error capture and server reporting
  • src/debug-panel.ts โ€” On-screen debug console
  • src/utils.ts โ€” Utility functions
  • src/types.ts โ€” TypeScript type definitions

API Endpoints

Method Endpoint Description
GET / Serves the single-page application
GET /api/files?path=<path> Lists directory contents as JSON
GET /api/download/<path> Downloads a file
GET /api/read/<path> Reads a text file (JSON response)
PUT /api/save/<path> Saves a text file
POST /api/upload?path=<path> Uploads one or more files
POST /api/create-file Creates a new empty file
POST /api/create-directory Creates a new directory
DELETE /api/delete/<path> Deletes a file or empty directory
POST /api/log Receives client-side error logs

Browser Compatibility

The frontend is compiled to ES5 and uses only APIs available in Safari on iOS 10:

  • XMLHttpRequest instead of fetch
  • Classical function expressions (no arrow functions in output)
  • var declarations (no let/const in output)
  • Prefixed CSS flexbox properties
  • No CSS Grid
  • No ES6 module syntax in output

Debug Panel

A floating debug button (โ˜ข) appears in the bottom-right corner of the page. Tapping it reveals an on-screen console that shows:

  • Client-side errors and warnings
  • Navigation events
  • API request results

All debug messages are also sent to the server and logged to the terminal, allowing inspection even without access to the browser's developer tools.

Progressive Web App (PWA)

This application can be installed as a PWA on modern browsers. However, PWA requires HTTPS to function properly.

Without HTTPS, the app will still work as a standard web page but won't have offline capabilities or installability.

About

A local file server with a web-based UI for browsing, uploading, editing, and downloading files targeting Safari 10.3.3 (iPad 4) and IE11 browser.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages