diff --git a/app/server.py b/app/server.py index 1502cf0..02baa83 100644 --- a/app/server.py +++ b/app/server.py @@ -21,7 +21,7 @@ import time import urllib.request from http.server import BaseHTTPRequestHandler, ThreadingHTTPServer from pathlib import Path -from urllib.parse import parse_qs, urlparse +from urllib.parse import parse_qs, quote, urlparse # Sibling modules: db (SQLite, paths), llama (model servers), memory (Q&A). import db @@ -54,7 +54,16 @@ NOPROXY = urllib.request.build_opener(urllib.request.ProxyHandler({})) # Edge path; %ProgramFiles(x86)% expanded by Windows env. EDGE = Path(os.path.expandvars(r"%ProgramFiles(x86)%\Microsoft\Edge\Application\msedge.exe")) PRINT_CSS = ( - "@media print{body{max-width:none;padding:0}img,tr{break-inside:avoid}h2,h3{break-after:avoid}}" + "@page{margin:15mm}" + "@media print{:root{--bg:#fff;--card:#fff;--soft:#f3f3f3;--line:#ccc}html,body{background:#fff}" + "body{max-width:none;padding:0;font-size:9pt;line-height:1.5}" + "h1{font-size:16pt}h2{font-size:12pt;margin-top:1.6em;border-top:0;padding-top:0}" + "table{font-size:8.5pt;border-radius:0;border:0;border-top:1px solid #999;border-bottom:1px solid #999}" + "td,th{padding:4px 8px}th{background:#eee}" + "#in-breve+ul{border-radius:0;padding:10px 16px 10px 2em}" + "details{border:0;padding:0;margin-top:1em;background:none}summary{display:none}" + "img{border-radius:0;max-width:100%}code{border-radius:0}" + "img,tr{break-inside:avoid}h2,h3{break-after:avoid}}" ) # Serializes ask_once: one llama start/stop at a time. LOCK = threading.Lock() @@ -876,10 +885,14 @@ class Handler(BaseHTTPRequestHandler): if file_path is None: self._send(b"not found", 404) else: + # File name from the report