Flask extension for remote downloads and progress streaming
Project description
Flask-Stream
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
-
SSH File Downloads
- Connect to remote servers via SSH key authentication.
- Recursive file listing on remote servers.
- Real-time file download progress updates.
-
Multiple Servers Support
- Configure one or multiple servers in the Flask app.
- Each server can have its own
remote_baseand download folder. - The UI clearly differentiates which server each file comes from.
-
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.
-
Parallel Downloads (Optional)
- Controlled via
STREAM_BULK_DOWNLOADandSTREAM_MAX_SIMULTANEOUS. - Downloads multiple files at once respecting the concurrency limit.
- Useful for large datasets or multiple servers.
- Controlled via
-
Ready-to-use HTML/JavaScript UI
- Includable download button via
{{ stream_button() }}. - Shows logs, errors, and dynamic progress using Server-Sent Events (SSE).
- Fully compatible with Bootstrap 5 for responsive styling.
- Includable download button via
-
Extensible Architecture
- Implements a
StreamProviderbase, enabling future stream types (HTTP, FTP, S3, etc.). - Supports
init_app()pattern for multiple Flask apps in the same process.
- Implements a
-
Asynchronous Job Management
- Each download job runs in a separate thread.
- Event queues per job enable real-time UI updates and multiple concurrent jobs.
-
Error Handling
- Stream errors reported in UI.
- Disconnects from server or app are shown as "Server or App disconnected".
-
Centralized Configuration
- Configure all parameters via
app.configor 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
- Configure all parameters via
-
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file flask_stream-1.0.7.tar.gz.
File metadata
- Download URL: flask_stream-1.0.7.tar.gz
- Upload date:
- Size: 11.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
795becff242d922e9704e1ab8eebb1f35f8cba233dc9f3a3ef991b1bf47a7260
|
|
| MD5 |
57a191e4d96a41427c65feeeef32a045
|
|
| BLAKE2b-256 |
723f8687c1d7e731c23f1cc07802d1568669b1830c038f22b98be01b227f5359
|
Provenance
The following attestation bundles were made for flask_stream-1.0.7.tar.gz:
Publisher:
publish.yml on P3r4nD/flask-stream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_stream-1.0.7.tar.gz -
Subject digest:
795becff242d922e9704e1ab8eebb1f35f8cba233dc9f3a3ef991b1bf47a7260 - Sigstore transparency entry: 1239264663
- Sigstore integration time:
-
Permalink:
P3r4nD/flask-stream@278cadaef10f943bd46ff91e2bd1332dc61abf11 -
Branch / Tag:
refs/tags/v1.0.7 - Owner: https://github.com/P3r4nD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@278cadaef10f943bd46ff91e2bd1332dc61abf11 -
Trigger Event:
release
-
Statement type:
File details
Details for the file flask_stream-1.0.7-py3-none-any.whl.
File metadata
- Download URL: flask_stream-1.0.7-py3-none-any.whl
- Upload date:
- Size: 10.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a7cbd384f36e4f1d741cb1dfca83fd7e27c0c76e101b832a49088ea8dc070c35
|
|
| MD5 |
8e8b0bb4a84e66e293e46f5b7556920c
|
|
| BLAKE2b-256 |
745e84da9b27b587d13e18050c7fa4132951cfbed338506014fd2a2606021be6
|
Provenance
The following attestation bundles were made for flask_stream-1.0.7-py3-none-any.whl:
Publisher:
publish.yml on P3r4nD/flask-stream
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
flask_stream-1.0.7-py3-none-any.whl -
Subject digest:
a7cbd384f36e4f1d741cb1dfca83fd7e27c0c76e101b832a49088ea8dc070c35 - Sigstore transparency entry: 1239264667
- Sigstore integration time:
-
Permalink:
P3r4nD/flask-stream@278cadaef10f943bd46ff91e2bd1332dc61abf11 -
Branch / Tag:
refs/tags/v1.0.7 - Owner: https://github.com/P3r4nD
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@278cadaef10f943bd46ff91e2bd1332dc61abf11 -
Trigger Event:
release
-
Statement type: