Quick Info
Host:
{html.escape(hostname)}
URL:
{html.escape(f"http://{self._get_local_ip()}:%s/")}
Status:
Server running
No content is currently being shared.
#!/usr/bin/env python3 import socket import threading import mimetypes from pathlib import Path from typing import List, Optional, Callable from http.server import HTTPServer, BaseHTTPRequestHandler import html import json def format_size(bytes_val: int) -> str: if bytes_val is None: return "" if bytes_val < 1024: return f"{bytes_val} Bytes" elif bytes_val < 1024**2: return f"{bytes_val/1024:.2f} KB" elif bytes_val < 1024**3: return f"{bytes_val/1024**2:.2f} MB" else: return f"{bytes_val/1024**3:.2f} GB" class FileShareHandler(BaseHTTPRequestHandler): shared_files: List[str] = [] shared_text: Optional[str] = None on_download: Optional[Callable[[str, str], None]] = None def log_message(self, format, *args): pass def _get_base_html(self, title: str, body_content: str, initial_data_script: str = "") -> str: return f"""
Total Size:
{format_size(total_size_bytes)}
Host:
{html.escape(hostname)}
URL:
{html.escape(f"http://{self._get_local_ip()}:%s/")}
Status:
Server running
No content is currently being shared.