File size: 702 Bytes
4f04d05
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
"""Probe: confirm sdk: gradio Spaces autoboot a gradio.Server app.

Push this as the only Python file in a throwaway Space copy with
sdk: gradio and verify both routes return 200. If they do, the design's
sdk: gradio assumption holds and we proceed. If they don't, halt and
execute fallback 2a (plain FastAPI host) per the spec.
"""
import gradio
from fastapi.responses import HTMLResponse

app = gradio.Server()


@app.get("/", response_class=HTMLResponse)
async def index():
    return "<!doctype html><html><body><h1>probe ok</h1></body></html>"


@app.api(name="ping")
def ping() -> dict:
    return {"ok": True}


if __name__ == "__main__":
    app.launch(server_name="0.0.0.0", server_port=7860)