websurfer/web/__init__.py
2026-11-07 16:58:29 +01:00

26 lines
964 B
Python

"""Web application package for Websurfer."""
from web.app import app
from web.manager import session_manager
def run_server(host: str = "127.0.0.1", port: int = 8000, reload: bool = False):
"""Starts the Websurfer FastAPI Web Dashboard server."""
import sys
import uvicorn
print("\n=======================================================")
print(f"[*] Websurfer Web UI running at http://{host}:{port}")
print(" Open this URL in your browser to configure & crawl.")
# On Windows, Uvicorn defaults to SelectorEventLoop when reload=True or workers > 1.
# Playwright requires ProactorEventLoop on Windows for asyncio subprocess support.
loop_arg = "asyncio:ProactorEventLoop" if sys.platform == "win32" else "auto"
uvicorn.run(
"web.app:app" if reload else app,
host=host,
port=port,
reload=reload,
proxy_headers=True,
forwarded_allow_ips="*",
loop=loop_arg,
)