Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,13 +1,23 @@
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
|
|
|
| 3 |
def ping():
|
| 4 |
return "pong 🎯"
|
| 5 |
|
| 6 |
with gr.Blocks(title="Boot Probe") as demo:
|
| 7 |
-
gr.Markdown("## Gradio boot OK? \nこの画面が出れば **Spaces がアプリを検出**できています。")
|
| 8 |
btn = gr.Button("Ping")
|
| 9 |
-
out = gr.Markdown()
|
| 10 |
btn.click(fn=ping, inputs=None, outputs=out)
|
| 11 |
|
| 12 |
-
#
|
| 13 |
-
app =
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from fastapi import FastAPI
|
| 2 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 3 |
import gradio as gr
|
| 4 |
|
| 5 |
+
# --- Gradio UI(超最小)
|
| 6 |
def ping():
|
| 7 |
return "pong 🎯"
|
| 8 |
|
| 9 |
with gr.Blocks(title="Boot Probe") as demo:
|
|
|
|
| 10 |
btn = gr.Button("Ping")
|
| 11 |
+
out = gr.Markdown("Click the button")
|
| 12 |
btn.click(fn=ping, inputs=None, outputs=out)
|
| 13 |
|
| 14 |
+
# --- FastAPI アプリを作成し、Gradioをマウント
|
| 15 |
+
app = FastAPI(title="Agent Studio - Python SDK")
|
| 16 |
+
|
| 17 |
+
app.add_middleware(
|
| 18 |
+
CORSMiddleware,
|
| 19 |
+
allow_origins=["*"], allow_credentials=True, allow_methods=["*"], allow_headers=["*"],
|
| 20 |
+
)
|
| 21 |
+
|
| 22 |
+
# ルートにGradioをマウント(/ でUIが出ます)
|
| 23 |
+
app = gr.mount_gradio_app(app, demo, path="/")
|