INNER CODE UNIT · Python
server_error_handler
alihaskar/pycharting · src/pycharting/core/server.py:223
async def server_error_handler(_request: Request, exc: Exception) -> JSONResponse: # pragma: no cover
"""Handle 500 errors."""
logger.error(f"Server error: {exc}")
return JSONResponse(status_code=500, content={"error": "Internal server error"})
return app
def run_server(
host: str = "127.0.0.1",
port: int | None = None,
auto_port: bool = True,
reload: bool = False,
) -> None:
"""Launch the PyCharting web server.
This function is the main entry point for running the server directly (e.g., for development).
It handles port selection, application creation, and starting the Uvicorn server process.