Spaces:
Runtime error

VcRlAgent commited on
Commit
7720322
·
1 Parent(s): 4eece65

Initial WorkWise backend merged main.py -> app.py

Browse files
Files changed (2) hide show
  1. app.py +14 -12
  2. app.py.min.working +2 -1
app.py CHANGED
@@ -1,24 +1,26 @@
1
  import gradio as gr
2
  from fastapi import FastAPI
 
3
 
4
- # Minimal FastAPI
5
  app = FastAPI()
6
 
7
- @app.get("/health")
8
- async def health():
9
- return {"status": "ok"}
10
-
11
- @app.get("/test")
12
- async def test():
13
  return {"message": "FastAPI is working"}
 
14
 
15
- # Minimal Gradio
16
- def echo(text):
17
- return f"You said: {text}"
 
 
18
 
19
- demo = gr.Interface(fn=echo, inputs="text", outputs="text")
 
 
20
 
21
- # Mount and get the app back
22
  app = gr.mount_gradio_app(app, demo, path="/")
23
 
24
  if __name__ == "__main__":
 
1
  import gradio as gr
2
  from fastapi import FastAPI
3
+ import spaces
4
 
 
5
  app = FastAPI()
6
 
7
+ @spaces.GPU
8
+ def your_gpu_function(input_data):
9
+ # Your GPU computation
 
 
 
10
  return {"message": "FastAPI is working"}
11
+ #return result
12
 
13
+ # FastAPI endpoint
14
+ @app.get("/api/predict")
15
+ async def predict(input: str):
16
+ result = your_gpu_function(input)
17
+ return {"result": result}
18
 
19
+ # Gradio interface (required for ZeroGPU)
20
+ with gr.Blocks() as demo:
21
+ gr.Interface(fn=your_gpu_function, inputs="text", outputs="text")
22
 
23
+ # Mount FastAPI to Gradio
24
  app = gr.mount_gradio_app(app, demo, path="/")
25
 
26
  if __name__ == "__main__":
app.py.min.working CHANGED
@@ -7,7 +7,8 @@ app = FastAPI()
7
  @spaces.GPU
8
  def your_gpu_function(input_data):
9
  # Your GPU computation
10
- return result
 
11
 
12
  # FastAPI endpoint
13
  @app.get("/api/predict")
 
7
  @spaces.GPU
8
  def your_gpu_function(input_data):
9
  # Your GPU computation
10
+ return {"message": "FastAPI is working"}
11
+ #return result
12
 
13
  # FastAPI endpoint
14
  @app.get("/api/predict")