Skip to main content

Flask extension for remote downloads and progress streaming

Project description

Flask-Stream 1.1.0

PyPI Python Version License: MIT CI

Flask-Stream is a Flask 3 extension that enables real-time streaming of file downloads from one or multiple remote servers directly in your web application's UI. It is designed to be easy to integrate, flexible, and extensible for future types of streams.


Features

  1. SSH File Downloads

    • Connect to remote servers via SSH key authentication.
    • Recursive file listing on remote servers.
    • Real-time file download progress updates.
  2. Multiple Servers Support

    • Configure one or multiple servers in the Flask app.
    • Each server can have its own remote_base and download folder.
    • The UI clearly differentiates which server each file comes from.
  3. Smart Progress Bars

    • Individual file progress: shows percentage and downloaded size (MB).
    • Total progress: tracks the progress over all files in the job.
    • For multiple simultaneous downloads, each active file has its own progress bar and filename.
  4. Parallel Downloads (Optional)

    • Controlled via STREAM_BULK_DOWNLOAD and STREAM_MAX_SIMULTANEOUS.
    • Downloads multiple files at once respecting the concurrency limit.
    • Useful for large datasets or multiple servers.
  5. Ready-to-use HTML/JavaScript UI

    • Includable download button via {{ stream_button() }}.
    • Tailwind, Bootstrap5 and custom UI template
    • Shows logs, errors, and dynamic progress using Server-Sent Events (SSE).
    • Fully compatible with Bootstrap 5 for responsive styling.
  6. Extensible Architecture

    • Implements a StreamProvider base, enabling future stream types (HTTP, FTP, S3, etc.).
    • Supports init_app() pattern for multiple Flask apps in the same process.
  7. Asynchronous Job Management

    • Each download job runs in a separate thread.
    • Event queues per job enable real-time UI updates and multiple concurrent jobs.
  8. Error Handling

    • Stream errors reported in UI.
    • Disconnects from server or app are shown as "Server or App disconnected".
  9. Centralized Configuration

    • Configure all parameters via app.config or a central config file.
    • Main configuration variables:
      STREAM_PROVIDER          # Currently "ssh"
      STREAM_SERVERS           # List of servers with host, user, key, remote_base, name
      STREAM_DOWNLOAD_DIR      # Local download directory
      STREAM_BULK_DOWNLOAD     # Enable parallel downloads
      STREAM_MAX_SIMULTANEOUS  # Max simultaneous downloads
      
  10. Integrated Tests

    • Unit tests with pytest covering routes, events, and basic functionality.
    • Installable in editable mode with pip install -e .[dev].

Installation

# Clone repository
git clone https://github.com/P3r4nD/flask-stream.git
cd flask-stream

# Install with dev dependencies
pip install -e .[dev]

# Or from PyPI
pip install flask-stream

Basic usage

from flask import Flask
from flask_stream import Stream

app = Flask(__name__)
app.config.update({
    "STREAM_SERVERS": [
        {"name": "server1", "host": "example.com", "user": "ubuntu", "key": "~/.ssh/id_rsa", "remote_base": "logs"},
        {"name": "server2", "host": "example2.com", "user": "ubuntu", "key": "~/.ssh/id_rsa", "remote_base": "logs"}
    ],
    "STREAM_DOWNLOAD_DIR": "downloads",
    "STREAM_BULK_DOWNLOAD": True,
    "STREAM_MAX_SIMULTANEOUS": 2
})

stream = Stream(app)

@app.route("/")
def index():
    return """
    <h3>Download Logs</h3>
    {{ stream_button() }}
    """

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

flask_stream-1.1.1.tar.gz (12.1 kB view details)

Uploaded Source

Built Distribution

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

flask_stream-1.1.1-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

File details

Details for the file flask_stream-1.1.1.tar.gz.

File metadata

  • Download URL: flask_stream-1.1.1.tar.gz
  • Upload date:
  • Size: 12.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flask_stream-1.1.1.tar.gz
Algorithm Hash digest
SHA256 21d5dfae4659c9f7a213232c971fc640e5bcd1dadfa9b1eaf3dab80a908f1f35
MD5 d2c01ea50c23517a2d79d4d5fb256115
BLAKE2b-256 965c5eedfb7c0dd70b1e6fb986d2ada6f0139c21845aac6d76299aac1f8d215d

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_stream-1.1.1.tar.gz:

Publisher: publish.yml on P3r4nD/Flask-Stream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file flask_stream-1.1.1-py3-none-any.whl.

File metadata

  • Download URL: flask_stream-1.1.1-py3-none-any.whl
  • Upload date:
  • Size: 16.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for flask_stream-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1b5717a7b214b782af525fa585ffd0c9601b19d0604bb910730a4e671348cab9
MD5 ce0e6a7e92fba631f03bcec629c32e77
BLAKE2b-256 ee10a72b5d9877544aa17c4a3c824b6fcbdd94b2e2c203db9faf443c4c92062e

See more details on using hashes here.

Provenance

The following attestation bundles were made for flask_stream-1.1.1-py3-none-any.whl:

Publisher: publish.yml on P3r4nD/Flask-Stream

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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