Spaces:
Running
Running
Download components/pro/web_sandbox/demos/error_handling.py from modelscope/modelscope-studio: direct link, hf CLI and curl.
- Browser
- Download file 932 Bytes
-
https://huggingface.co/spaces/modelscope/modelscope-studio/resolve/main/components/pro/web_sandbox/demos/error_handling.py
- Command line
-
hf download hf://spaces/modelscope/modelscope-studio/components/pro/web_sandbox/demos/error_handling.py
-
curl -L -o error_handling.py https://huggingface.co/spaces/modelscope/modelscope-studio/resolve/main/components/pro/web_sandbox/demos/error_handling.py
932 Bytes
| import gradio as gr | |
| import modelscope_studio.components.antd as antd | |
| import modelscope_studio.components.base as ms | |
| import modelscope_studio.components.pro as pro | |
| with gr.Blocks() as demo, ms.Application(), antd.ConfigProvider(): | |
| antd.Divider("Render Error") | |
| pro.WebSandbox(value={ | |
| "index.tsx": | |
| """ | |
| export default function App() { | |
| return <button onClick={() => { | |
| throw new Error('Test Error'); | |
| } }>Click to throw error</button>; | |
| } | |
| """ | |
| }, | |
| template="react") | |
| antd.Divider("Compile Error") | |
| pro.WebSandbox(value={}, template="react") | |
| antd.Divider("Custom Compile Error Render") | |
| with pro.WebSandbox(value={}, template="react"): | |
| with ms.Slot("compileErrorRender", | |
| params_mapping="(message) => ({ sub_title: message })"): | |
| antd.Result(status="error", title="Compile Error") | |
| if __name__ == "__main__": | |
| demo.queue().launch() | |