Без опису

Geovanny Andrés Vega Mite ca95544ee3 feat(media): add support for HEIC/HEIF images and PDF files 3 місяців тому
static ca95544ee3 feat(media): add support for HEIC/HEIF images and PDF files 3 місяців тому
templates ca95544ee3 feat(media): add support for HEIC/HEIF images and PDF files 3 місяців тому
.gitignore a06bcbc2e4 Init 5 місяців тому
README.md 154cd09ead feat(file-preview): add archive file preview support for ZIP, TAR and RAR files 3 місяців тому
app.py ca95544ee3 feat(media): add support for HEIC/HEIF images and PDF files 3 місяців тому
requirements.txt 7d4b8d2233 HokoriTemp V2 5 місяців тому

README.md

📁 Flask Temporary File Upload

A lightweight Flask web application for temporary file uploads with automatic expiration and cleanup.

⚡ Quick Start

  1. Clone/Download and navigate to project folder
  2. Create virtual environment: python -m venv venv
  3. Activate environment:
    • Linux/Mac: source venv/bin/activate
    • Windows: venv\Scripts\activate
  4. Install dependencies: pip install -r requirements.txt
  5. Create templates folder: mkdir templates
  6. Place files:
    • app.py in root folder
    • index.html in templates/ folder
  7. Run: python app.py
  8. Open: http://localhost:5000

🚀 Usage Examples

# Basic (localhost only)
python app.py

# Network access (all devices on LAN)
python app.py --network

# Custom domain/URL
python app.py --base-url https://files.mysite.com

# Large files (100MB limit)
python app.py --max-file-size 100

# Production example
python app.py --network --port 8080 --max-file-size 50 --base-url https://uploads.mydomain.com

🔧 Command Options

Option Description Default
--host Bind to specific host 127.0.0.1
--port Port number 5000
--network Allow network access (0.0.0.0) False
--base-url Custom URL for download links auto
--max-file-size Max file size in MB 16
--debug Enable debug mode False

📋 Features

  • Drag & drop file upload
  • Automatic cleanup every 10 minutes
  • Custom expiration (1 hour to 1 week)
  • User sessions via localStorage
  • Secure filenames and validation
  • Responsive design with Tailwind CSS
  • Download links with custom domains
  • File management (upload/download/delete)
  • File preview for text files and JSON
  • Archive preview for ZIP, TAR, and RAR files
  • Download page with file information and preview
  • Dual download options (direct download vs. info page)

👁️ File Preview Features

Text File Preview

  • Supported formats: .txt, .json, .md, .csv, .log, and other text-based files
  • Real-time preview of file content before downloading
  • Syntax highlighting for JSON files
  • Error handling for unreadable text files

Archive File Preview

  • ZIP files: Complete file listing with compression ratios
  • TAR files: Support for .tar, .tar.gz, .tar.bz2, .tar.xz formats
  • RAR files: Optional support (requires rarfile library)
  • File information: Names, sizes, dates, and folder structure
  • Statistics: Total files and folders count
  • Visual indicators: Different icons for files and directories

Download Options

  • View button: Opens information page with preview
  • Download button: Direct file download from file list
  • Copy link: Share the information page URL
  • Modern UI: Responsive design with dark/light theme support

🗂️ Project Structure

project/
├── venv/                 # Virtual environment
├── app.py               # Main Flask application
├── requirements.txt     # Dependencies
├── templates/
│   ├── index.html      # Main web interface
│   └── download.html   # File information and preview page
├── static/
│   ├── css/
│   │   └── styles.css  # Custom styles
│   └── js/
│       └── main.js     # Frontend JavaScript
├── uploads/            # Files storage (auto-created)
└── files.db           # SQLite database (auto-created)

🌐 Network Access

  • Localhost only: python app.py
  • LAN access: python app.py --network
  • Custom host: python app.py --host 192.168.1.100

🔒 Security

  • Random 32-character secret key generated on startup
  • Filename sanitization prevents path traversal
  • Session-based file access (users only see their files)
  • Configurable file size limits
  • Automatic expired file cleanup

🛠️ Environment Variables

Set BASE_URL environment variable as alternative to --base-url:

export BASE_URL=https://files.mysite.com
python app.py --network

📦 Optional Dependencies

For RAR file preview support, install the rarfile library:

pip install rarfile

Note: RAR support also requires the UnRAR library to be installed on your system:

  • Windows: Download UnRAR from WinRAR website
  • Linux: sudo apt-get install unrar or sudo yum install unrar
  • macOS: brew install unrar

Without rarfile, the application will work normally but won't preview RAR archives.

📝 File Expiration

Users can set file duration when uploading:

  • 1 Hour
  • 6 Hours
  • 24 Hours (default)
  • 3 Days
  • 1 Week

Files are automatically deleted after expiration.

🔍 Help

python app.py --help

Ready to go! 🎉 Your temporary file upload server will be running with automatic cleanup and a modern web interface.