Spaces:
Running on Zero
Running on Zero
Siddharth Ravikumar commited on
Commit ·
47ed39d
1
Parent(s): aef3662
Mount Gradio at / to satisfy ZeroGPU proxy limits
Browse files- app.py +1 -2
- frontend/js/alt_app.js +2 -2
- test_spaces.py +11 -0
app.py
CHANGED
|
@@ -881,11 +881,10 @@ async def serve_upload(path: str):
|
|
| 881 |
return FileResponse(str(filepath))
|
| 882 |
|
| 883 |
# Mount Gradio app at /gradio
|
| 884 |
-
# Note: Since ZeroGPU uses the main app module, we must export `app` itself as the Gradio wrapper. HF Spaces uses app.py
|
| 885 |
app = gr.mount_gradio_app(
|
| 886 |
app,
|
| 887 |
demo,
|
| 888 |
-
path="/
|
| 889 |
)
|
| 890 |
|
| 891 |
# Startup event wrapper
|
|
|
|
| 881 |
return FileResponse(str(filepath))
|
| 882 |
|
| 883 |
# Mount Gradio app at /gradio
|
|
|
|
| 884 |
app = gr.mount_gradio_app(
|
| 885 |
app,
|
| 886 |
demo,
|
| 887 |
+
path="/"
|
| 888 |
)
|
| 889 |
|
| 890 |
# Startup event wrapper
|
frontend/js/alt_app.js
CHANGED
|
@@ -18,7 +18,7 @@ let additionalFiles = []; // For add photos modal
|
|
| 18 |
|
| 19 |
// Gradio API Helper for ZeroGPU Event Streams
|
| 20 |
async function callGradioApi(apiName, dataArr) {
|
| 21 |
-
const res = await fetch('/
|
| 22 |
method: 'POST',
|
| 23 |
headers: { 'Content-Type': 'application/json' },
|
| 24 |
body: JSON.stringify({ data: dataArr })
|
|
@@ -32,7 +32,7 @@ async function callGradioApi(apiName, dataArr) {
|
|
| 32 |
const eventId = eventObj.event_id;
|
| 33 |
|
| 34 |
return new Promise((resolve, reject) => {
|
| 35 |
-
const source = new EventSource('/
|
| 36 |
source.onmessage = (e) => {
|
| 37 |
const msg = JSON.parse(e.data);
|
| 38 |
if (msg.msg === 'process_completed') {
|
|
|
|
| 18 |
|
| 19 |
// Gradio API Helper for ZeroGPU Event Streams
|
| 20 |
async function callGradioApi(apiName, dataArr) {
|
| 21 |
+
const res = await fetch('/call/' + apiName, {
|
| 22 |
method: 'POST',
|
| 23 |
headers: { 'Content-Type': 'application/json' },
|
| 24 |
body: JSON.stringify({ data: dataArr })
|
|
|
|
| 32 |
const eventId = eventObj.event_id;
|
| 33 |
|
| 34 |
return new Promise((resolve, reject) => {
|
| 35 |
+
const source = new EventSource('/call/' + apiName + '/' + eventId);
|
| 36 |
source.onmessage = (e) => {
|
| 37 |
const msg = JSON.parse(e.data);
|
| 38 |
if (msg.msg === 'process_completed') {
|
test_spaces.py
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import spaces
|
| 2 |
+
import gradio as gr
|
| 3 |
+
|
| 4 |
+
@spaces.GPU()
|
| 5 |
+
def test_fn():
|
| 6 |
+
return "Hello"
|
| 7 |
+
|
| 8 |
+
with gr.Blocks() as demo:
|
| 9 |
+
btn = gr.Button("Test")
|
| 10 |
+
out = gr.Textbox()
|
| 11 |
+
btn.click(test_fn, outputs=out)
|