Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/heartsucker/flask-rangerequest
Range request (RFC 7233) support for your Flask app.
https://github.com/heartsucker/flask-rangerequest
flask http python
Last synced: 3 months ago
JSON representation
Range request (RFC 7233) support for your Flask app.
- Host: GitHub
- URL: https://github.com/heartsucker/flask-rangerequest
- Owner: heartsucker
- License: apache-2.0
- Created: 2018-10-12T09:39:27.000Z (over 6 years ago)
- Default Branch: develop
- Last Pushed: 2021-08-29T11:53:53.000Z (over 3 years ago)
- Last Synced: 2024-09-17T15:49:52.906Z (4 months ago)
- Topics: flask, http, python
- Language: Python
- Size: 28.3 KB
- Stars: 4
- Watchers: 5
- Forks: 1
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# Flask-RangeRequest
[![PyPI Version](https://badge.fury.io/py/Flask-RangeRequest.svg)](https://pypi.python.org/pypi/Flask-RangeRequest) [![CI](https://api.travis-ci.org/heartsucker/flask-rangerequest.svg?branch=develop)](https://api.travis-ci.org/heartsucker/flask-rangerequest.svg?branch=develop) [![Documentation Status](https://readthedocs.org/projects/flask-rangerequest/badge/?version=latest)](https://flask-rangerequest.readthedocs.io/en/latest/?badge=latest)`Flask-RangeRequest` adds range request ([RFC 7233](https://tools.ietf.org/html/rfc7233)) support to your Flask app.
## Example
```python
from datetime import datetime
from flask import Flask
from flask_rangerequest import RangeRequest
from os import pathmy_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](./LICENSE-MIT)
and [LICENSE-APACHE](./LICENSE-APACHE) for details.