AsyncCoder-10 commited on
Commit
ca36815
·
verified ·
1 Parent(s): cd1b31b

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -0
app.py ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 1. MUST be the very first import
2
+ import spaces
3
+ import gradio as gr
4
+ from fastapi import FastAPI
5
+ from app.main import app as fastapi_app
6
+
7
+ # 2. Dummy GPU function
8
+ @spaces.GPU
9
+ def dummy_gpu_check():
10
+ return "ZeroGPU Hardware Connected!"
11
+
12
+ # 3. Create the Gradio UI with a button that calls the GPU function
13
+ with gr.Blocks() as demo:
14
+ gr.Markdown("# 🛡️ Moderation API")
15
+ gr.Markdown("This is a live API. Send POST requests to `/api/v1/moderate`.")
16
+ gr.Markdown("You can view the interactive API docs at [here](/docs) once it starts.")
17
+
18
+ # This button satisfies the ZeroGPU AST parser
19
+ with gr.Row():
20
+ btn = gr.Button("Test ZeroGPU Connection")
21
+ output = gr.Textbox()
22
+ btn.click(fn=dummy_gpu_check, inputs=[], outputs=output)
23
+
24
+ # 4. Mount FastAPI
25
+ app = gr.mount_gradio_app(fastapi_app, demo, path="/")