pigeon.files.static

Module Contents

class pigeon.files.static.Manager

Used to manage settings and load specified middleware which is only loaded at runtime.

To override settings either the method Manager.override or the Manager.__get_attr__ method is used:

# override settings using a module or similar behaving object
my_settings: types.ModuleType = ...
Manager.override(my_settings)

# override settings one at a time by accessing the attributes (__getattr__)
Manager.my_setting = my_value
classmethod override(new_settings: types.ModuleType | Any)

Overrides current settings with new settings provided.

Parameters:

new_settings – New settings to override old ones with

class pigeon.files.static.HTTPRequest(method: str, path: str, headers: dict = None, get: dict = None, data=None, files=None, protocol: str = '1.1', content_type=None, **kwargs)

Bases: pigeon.http.message.HTTPMessage

An HTTP message (obv either response or request)

property is_error
class pigeon.files.static.HTTPResponse(headers: dict = None, data: str = None, status: int = 200, cookies=None, protocol: str = '1.1', content_type=None, **kwargs)

Bases: pigeon.http.message.HTTPMessage

An HTTP message (obv either response or request)

property is_error
pigeon.files.static.error(code: int, request: pigeon.http.request.HTTPRequest | None = None) pigeon.http.response.HTTPResponse | str

Returns the HTTPResponse for the error code provided, request parameter optional

pigeon.files.static.loaded_files
pigeon.files.static.load()

loads smaller static files into memory

pigeon.files.static.load_file(local_path: pathlib.Path)

Tries loading a file into memory and compress it. If the file is too large, nothing will be returned.

pigeon.files.static.fetch_file(local_path: pathlib.Path, encodings)

Returns file at the requested path using possible encoding

pigeon.files.static.handle_static_request(request: pigeon.http.HTTPRequest)