Files
auto_news_upload/test/serve_fixture.py
T
2026-10-31 16:15:04 +08:00

20 lines
735 B
Python

"""Temporary local UI fixture; never contacts the news API or forum."""
from pathlib import Path
import sys
import tempfile
from http.server import ThreadingHTTPServer
ROOT = Path(__file__).resolve().parents[1]
sys.path.insert(0, str(ROOT))
from app import Controller, make_handler
with tempfile.TemporaryDirectory() as temp:
controller = Controller(Path(temp) / 'data', Path(temp) / 'downloads', ledger=None)
controller.store.enqueue(ROOT / 'test/fixtures/article')
server = ThreadingHTTPServer(('127.0.0.1', 8771), make_handler(controller))
print('UI fixture listening on 8771', flush=True)
try:
server.serve_forever()
except KeyboardInterrupt:
pass
finally:
server.server_close()