archivebox.misc.serve_static

Module Contents

Classes

RangedFileReader

Wraps a file like object with an iterator that runs over part (or all) of the file defined by start and stop. Blocks of block_size will be returned from the starting position, up to, but not including the stop point. https://github.com/satchamo/django/commit/2ce75c5c4bee2a858c0214d136bfcd351fcde11d

Functions

serve_static_with_byterange_support

Overrides Django’s built-in django.views.static.serve function to support byte range requests. This allows you to do things like seek into the middle of a huge mp4 or WACZ without downloading the whole file. https://github.com/satchamo/django/commit/2ce75c5c4bee2a858c0214d136bfcd351fcde11d

serve_static

Serve static files below a given point in the directory structure or from locations inferred from the staticfiles finders.

parse_range_header

Parses a range header into a list of two-tuples (start, stop) where start is the starting byte of the range (inclusive) and stop is the ending byte position of the range (exclusive). Returns None if the value of the header is not syntatically valid. https://github.com/satchamo/django/commit/2ce75c5c4bee2a858c0214d136bfcd351fcde11d

API

archivebox.misc.serve_static.serve_static_with_byterange_support(request, path, document_root=None, show_indexes=False)[source]

Overrides Django’s built-in django.views.static.serve function to support byte range requests. This allows you to do things like seek into the middle of a huge mp4 or WACZ without downloading the whole file. https://github.com/satchamo/django/commit/2ce75c5c4bee2a858c0214d136bfcd351fcde11d

archivebox.misc.serve_static.serve_static(request, path, **kwargs)[source]

Serve static files below a given point in the directory structure or from locations inferred from the staticfiles finders.

To use, put a URL pattern such as::

from django.contrib.staticfiles import views

path('<path:path>', views.serve)

in your URLconf.

It uses the django.views.static.serve() view to serve the found files.

archivebox.misc.serve_static.parse_range_header(header, resource_size)[source]

Parses a range header into a list of two-tuples (start, stop) where start is the starting byte of the range (inclusive) and stop is the ending byte position of the range (exclusive). Returns None if the value of the header is not syntatically valid. https://github.com/satchamo/django/commit/2ce75c5c4bee2a858c0214d136bfcd351fcde11d

class archivebox.misc.serve_static.RangedFileReader(file_like, start=0, stop=float('inf'), block_size=None)[source]

Wraps a file like object with an iterator that runs over part (or all) of the file defined by start and stop. Blocks of block_size will be returned from the starting position, up to, but not including the stop point. https://github.com/satchamo/django/commit/2ce75c5c4bee2a858c0214d136bfcd351fcde11d

Initialization

block_size[source]

8192

__iter__()[source]