Spaces:
Build error
Build error
| """Desktop wrapper for PageParse using pywebview. | |
| Usage: python -m pageparse.desktop | |
| Requires: pip install pywebview | |
| """ | |
| from __future__ import annotations | |
| import threading | |
| import webbrowser | |
| import uvicorn | |
| from pageparse.web import app as fastapi_app | |
| def start_desktop_app() -> None: | |
| try: | |
| import webview | |
| except ImportError: | |
| print("pywebview not installed. Install with: pip install pageparse[desktop]") | |
| print("Falling back to browser...") | |
| webbrowser.open("http://127.0.0.1:8000") | |
| return | |
| def run_server(): | |
| uvicorn.run(fastapi_app, host="127.0.0.1", port=8000, log_level="warning") | |
| server_thread = threading.Thread(target=run_server, daemon=True) | |
| server_thread.start() | |
| webview.create_window( | |
| "PageParse", | |
| "http://127.0.0.1:8000", | |
| width=1280, | |
| height=800, | |
| min_size=(800, 600), | |
| resizable=True, | |
| text_select=True, | |
| ) | |
| webview.start() | |
| if __name__ == "__main__": | |
| start_desktop_app() | |