Commit b8bd8ce4 authored by AUTOMATIC1111's avatar AUTOMATIC1111
Browse files

disable rich exception output in console for API by default, use...

disable rich exception output in console for API by default, use WEBUI_RICH_EXCEPTIONS env var to enable
parent 95ee0cb1
Loading
Loading
Loading
Loading
+18 −15
Original line number Diff line number Diff line
import base64
import io
import os
import time
import datetime
import uvicorn
@@ -98,14 +99,16 @@ def encode_pil_to_base64(image):


def api_middleware(app: FastAPI):
    rich_available = True
    rich_available = False
    try:
        if os.environ.get('WEBUI_RICH_EXCEPTIONS', None) is not None:
            import anyio  # importing just so it can be placed on silent list
            import starlette  # importing just so it can be placed on silent list
            from rich.console import Console
            console = Console()
            rich_available = True
    except Exception:
        rich_available = False
        pass

    @app.middleware("http")
    async def log_and_time(req: Request, call_next):