diff --git a/gradio/app.py b/gradio/app.py index e46ad416b4..b79131a98d 100644 --- a/gradio/app.py +++ b/gradio/app.py @@ -117,6 +117,14 @@ def static_resource(path: str): raise HTTPException(status_code=404, detail="Static file not found") +@app.get('/favicon.ico') +async def favicon(): + if app.favicon_path: + return FileResponse(app.favicon_path) + else: + raise HTTPException(status_code=404, detail="Favicon file not found") + + @app.get("/api", response_class=HTMLResponse) # Needed for Spaces @app.get("/api/", response_class=HTMLResponse) def api_docs(request: Request): @@ -307,6 +315,9 @@ if __name__ == '__main__': # Run directly for debugging: python app.py app.interface.config = app.interface.get_config_file() app.interface.show_error = True app.interface.flagging_callback.setup(app.interface.flagging_dir) + app.favicon_path = None + app.tokens = {} + auth = True if auth: app.interface.auth = ("a", "b") @@ -314,5 +325,5 @@ if __name__ == '__main__': # Run directly for debugging: python app.py app.interface.auth_message = None else: app.auth = None - app.tokens = {} + uvicorn.run(app) diff --git a/gradio/interface.py b/gradio/interface.py index 697134b2b0..6c7b93b9db 100644 --- a/gradio/interface.py +++ b/gradio/interface.py @@ -518,7 +518,8 @@ class Interface: height: int = 500, width: int = 900, encrypt: bool = False, - cache_examples: bool = False + cache_examples: bool = False, + favicon_path: Optional[str] = None, ) -> Tuple[flask.Flask, str, str]: """ Launches the webserver that serves the UI for the interface. @@ -540,6 +541,7 @@ class Interface: height (int): The height in pixels of the