mdvtools.server_utils#
Utility functions for Flask-based servers in the MDV project.
This module provides common server utilities including security headers, file serving helpers, and HTTP range request handling.
Functions#
|
Add security and CORS headers to a Flask response. |
|
Send a file using Flask's send_file with absolute path handling. |
|
Handle HTTP range requests for partial file content. |
Module Contents#
- mdvtools.server_utils.add_safe_headers(resp)[source]#
Add security and CORS headers to a Flask response.
- Parameters:
resp – Flask response object to modify
- Returns:
Modified response object with added headers
- mdvtools.server_utils.send_file(f)[source]#
Send a file using Flask’s send_file with absolute path handling.
- Parameters:
f (str) – File path (relative or absolute)
- Returns:
Flask response object for the file
- mdvtools.server_utils.get_range(file_name, range_header)[source]#
Handle HTTP range requests for partial file content.
- Parameters:
file_name (str) – Path to the file to serve
range_header (str) – HTTP Range header value
- Returns:
Flask Response object with partial content (status 206)
- Raises:
ValueError – If the range header is invalid