Skip to main content

A flexible file upload server with Flask and predefined upload destinations

Project description

flexup

A flexible file upload server with Flask that provides predefined upload destinations.

Similar to uploadserver, but built with Flask and allows you to configure multiple named upload destinations that clients can choose from.

Features

  • File serving with directory browsing
  • Web-based file upload interface
  • Multiple predefined upload destinations
  • Secure filename handling and path traversal prevention
  • HTTP Basic Authentication support
  • File type validation (whitelist/blacklist)
  • Human-readable file sizes in listings
  • Command-line interface

Installation

pip install flexup

Usage

Basic usage (uploads to root directory):

flexup

Specify a custom directory:

flexup -D /path/to/serve

Define multiple upload destinations:

flexup -d images=uploads/images -d docs=uploads/documents -d videos=uploads/videos

Custom port:

flexup --port 8080

With authentication and security:

flexup -D /var/www \
  --basic-auth admin:secret123 \
  --allow-exts txt,pdf,jpg,png \
  --host 127.0.0.1 \
  --port 8080

This will:

  • Serve files from /var/www
  • Require authentication (username: admin, password: secret123)
  • Only allow specific file types
  • Bind to localhost only
  • Run on port 8080

Command-Line Options

-D, --directory    Root directory to serve files from [default: current directory]
-d, --dest         Define upload destination: key=path (can be used multiple times)
--host             Host address to bind to [default: 0.0.0.0 (all interfaces)]
--port             Port to run the server on [default: 5000]
--basic-auth       Enable HTTP Basic Auth: username:password
--allow-exts       Comma-separated list of allowed file extensions (whitelist)
--block-exts       Comma-separated list of blocked file extensions (blacklist)
                   [default blocks: exe,sh,bat,cmd,com,pif,scr,vbs,js,jar,app,deb,rpm]

Security Options

Authentication:

flexup --basic-auth admin:secret123

Bind to localhost only:

flexup --host 127.0.0.1

File type whitelist (most secure):

flexup --allow-exts txt,pdf,jpg,png,gif

File type blacklist (block executables):

flexup --block-exts exe,sh,bat,js

Disable default blocklist (not recommended):

flexup --block-exts ""

Web Interface

Once running, access:

  • http://localhost:5000/ - Browse and download files
  • http://localhost:5000/upload - Upload files to predefined destinations

Uploading with curl

Single File Upload

curl -X POST http://localhost:5000/upload -F "files=@filename.txt"

Multiple Files Upload

Upload multiple files in a single request:

curl -X POST http://localhost:5000/upload \
  -F "files=@file1.txt" \
  -F "files=@file2.txt" \
  -F "files=@file3.txt"

With Authentication

curl -X POST http://localhost:5000/upload \
  -u admin:secret123 \
  -F "files=@document.pdf"

Upload to Specific Destination

If you configured destinations:

flexup -d images=uploads/img -d docs=uploads/documents

Upload to specific destination:

# Single file to images
curl -X POST http://localhost:5000/upload \
  -F "files=@photo.jpg" \
  -F "destination_key=images"

# Multiple files to docs
curl -X POST http://localhost:5000/upload \
  -F "files=@report.pdf" \
  -F "files=@summary.pdf" \
  -F "destination_key=docs"

Bulk Upload

Upload all files in current directory:

curl -X POST http://localhost:5000/upload \
  $(for f in *.txt; do echo "-F files=@$f"; done)

Note: Successful uploads return 204 No Content (matching uploadserver behavior)

Development

Setup

Clone the repository and install development dependencies:

git clone https://github.com/dyay108/flexup.git
cd flexup
pip install -e ".[dev]"

Running Tests

pytest

Code Formatting

black src tests

Type Checking

mypy src

License

This project is licensed under the MIT License - see the LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

flexup-0.1.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

flexup-0.1.0-py3-none-any.whl (8.2 kB view details)

Uploaded Python 3

File details

Details for the file flexup-0.1.0.tar.gz.

File metadata

  • Download URL: flexup-0.1.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for flexup-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e22f50188643e75f8126c82e6671db4476d98119b7aa8d3a8db83cb737d0c999
MD5 f536891a59d5ab5b594423bd707b7416
BLAKE2b-256 7cfecce4738e0b62432609d669855bb6c61d8f97536b70341b8c31bdae71fba4

See more details on using hashes here.

File details

Details for the file flexup-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: flexup-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 8.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.1

File hashes

Hashes for flexup-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 f144016663b13c1b11415b107cdd9ade08138f4af6f17a8b3cd95f1194d590de
MD5 00d42e4d09ea7c1abb07b40deed581a7
BLAKE2b-256 ec20412aef3f3a9fed202bc96a8ff172bfd7d3c27c32063443bb5a7c092efef2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page