archivebox.misc.serve_static
Module Contents
Classes
Expose a write-only file-like object so zipfile can stream into a queue. |
|
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
Yield non-hidden files in a stable order so ZIP output is deterministic. |
|
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 files below a given point in the directory structure or from locations inferred from the staticfiles finders. |
|
Parses a range header into a list of two-tuples (start, stop) where |
Data
API
- archivebox.misc.serve_static._HASHES_CACHE: dict[pathlib.Path, tuple[float, dict[str, str]]][source]
None
- archivebox.misc.serve_static._load_hash_map(snapshot_dir: pathlib.Path) dict[str, str] | None[source]
- archivebox.misc.serve_static._hash_for_path(document_root: pathlib.Path, rel_path: str) str | None[source]
- class archivebox.misc.serve_static._StreamingQueueWriter(output_queue: queue.Queue[bytes | BaseException | object])[source]
Expose a write-only file-like object so zipfile can stream into a queue.
Initialization
- archivebox.misc.serve_static._iter_visible_files(root: pathlib.Path)[source]
Yield non-hidden files in a stable order so ZIP output is deterministic.
- archivebox.misc.serve_static._build_directory_zip_response(fullpath: pathlib.Path, path: str, *, is_archive_replay: bool, use_async_stream: bool) django.http.StreamingHttpResponse[source]
- archivebox.misc.serve_static._render_directory_index(request, path: str, fullpath: pathlib.Path) django.http.HttpResponse[source]
- archivebox.misc.serve_static._render_image_preview_document(image_url: str, title: str) str[source]
- archivebox.misc.serve_static._is_risky_replay_document(fullpath: pathlib.Path, content_type: str) bool[source]
- archivebox.misc.serve_static._apply_archive_replay_headers(response: django.http.HttpResponse, *, fullpath: pathlib.Path, content_type: str, is_archive_replay: bool) django.http.HttpResponse[source]
- archivebox.misc.serve_static.serve_static_with_byterange_support(request, path, document_root=None, show_indexes=False, is_archive_replay: bool = 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
startis the starting byte of the range (inclusive) andstopis the ending byte position of the range (exclusive). Returns None if the value of the header is not syntactically 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