Documentation / base / PythonHttpServerReader
Class: PythonHttpServerReader
Defined in: libs/base/src/vfs/readers/python_httpserver_reader.ts:22
Directory reader for Python's built-in http.server (and similar) HTML directory listings.
Remarks
- Detects pages served by Python's
http.serverby scanning the<title>or<h1>tags. - Parses
<ul><li><a>(default Python layout) and falls back to plain<a>links. - Skips parent directory entries (
../), external links, and anchors. - Attempts to extract file size and modification date from the link's surrounding text.
- Normalizes resolved paths via the provided
HttpDirectoryReaderContext.
Limitations:
- Parsing depends on the server's HTML structure; non-standard variants may not be fully parsed.
- Size and date extraction are best-effort and may be unavailable in some cases.
Implements
Constructors
Constructor
new PythonHttpServerReader():
PythonHttpServerReader
Returns
PythonHttpServerReader
Properties
name
readonlyname:"python-http-server"='python-http-server'
Defined in: libs/base/src/vfs/readers/python_httpserver_reader.ts:23
Human-readable name of this reader implementation (for diagnostics/logging).
Implementation of
Methods
canHandle()
canHandle(
dirPath,ctx):Promise<boolean>
Defined in: libs/base/src/vfs/readers/python_httpserver_reader.ts:25
Optional probe that indicates whether this reader can handle the given directory.
Typical strategies:
- Check for a known index file (e.g., "index.json")
- HEAD/GET and inspect headers/content patterns
If omitted, the host may assume the reader can handle all directories.
Parameters
dirPath
string
Normalized directory path (typically ends with "/").
ctx
Context utilities for fetching and path handling.
Returns
Promise<boolean>
true if supported, otherwise false. May return a promise.
Implementation of
readOnce()
readOnce(
dirPath,ctx):Promise<FileMetadata[]>
Defined in: libs/base/src/vfs/readers/python_httpserver_reader.ts:39
Performs a single-pass listing of the directory at dirPath.
Requirements:
- Return only direct children of
dirPath(non-recursive). - Populate
FileMetadatafields as accurately as possible (name, path, type, size, timestamps, mimeType). - Use
ctx.normalizePath/ctx.joinPathto build stablepathfields.
Error handling:
- Throw on unrecoverable errors (the host VFS may fall back to other readers).
- Return an empty array if the directory is valid but contains no entries.
Parameters
dirPath
string
Normalized directory path to read (typically ends with "/").
ctx
Context utilities for network and path operations.
Returns
Promise<FileMetadata[]>
A promise resolving to a flat list of file/directory metadata.