flask-rangerequest 0.0.2


pip install flask-rangerequest

  Latest version

Released: Aug 29, 2021

Project Links

Meta
Author: heartsucker
Requires Python: >=3.6

Classifiers

Development Status
  • 4 - Beta

Intended Audience
  • Developers

License
  • OSI Approved :: Apache Software License
  • OSI Approved :: MIT License

Operating System
  • OS Independent

Programming Language
  • Python :: 3 :: Only
  • Python :: 3.6
  • Python :: 3.7
  • Python :: 3.8
  • Python :: 3.9

Flask-RangeRequest

PyPI Version CI Documentation Status

Flask-RangeRequest adds range request (RFC 7233) support to your Flask app.

Example

from datetime import datetime
from flask import Flask
from flask_rangerequest import RangeRequest
from os import path

my_file = '/path/to/file'
app = Flask(__name__)
size = path.getsize(my_file)
with open(my_file, 'rb') as f:
    etag = RangeRequest.make_etag(f)
last_modified = datetime.utcnow()

@app.route('/', methods=('GET', 'POST'))
def index():
    return RangeRequest(open(my_file, 'rb'),
                        etag=etag,
                        last_modified=last_modified,
                        size=size).make_response()

if __name__ == '__main__':
    app.run(host='127.0.0.1', port=8080, debug=True)

License

This work is dual licensed under the MIT and Apache-2.0 licenses. See LICENSE-MIT and LICENSE-APACHE for details.

Wheel compatibility matrix

Platform Python 3
any

Files in release

Extras: None
Dependencies:
Flask (>=2)