-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
37 lines (29 loc) · 1008 Bytes
/
Copy pathapp.py
File metadata and controls
37 lines (29 loc) · 1008 Bytes
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
27
28
29
30
31
32
33
34
35
36
37
import os
import sys
from pathlib import Path
# Add src and server to path
APP_ROOT = Path(__file__).resolve().parent
sys.path.append(str(APP_ROOT / "src"))
sys.path.append(str(APP_ROOT))
import spaces
import gradio as gr
from server.main import app as fastapi_app
# ZeroGPU requires at least one @spaces.GPU decorated function
@spaces.GPU
def health_check():
"""Dummy GPU function required by ZeroGPU Spaces."""
return "ClipNeuron API is running!"
# Gradio UI
with gr.Blocks() as demo:
gr.Markdown("# 🚀 ClipNeuron API Backend")
gr.Markdown(
"This Hugging Face Space hosts the ClipNeuron FastAPI backend.\n\n"
"API endpoints are available under `/api`."
)
btn = gr.Button("Health Check")
output = gr.Textbox(label="Status")
btn.click(fn=health_check, inputs=[], outputs=[output])
# Mount FastAPI under /api on Gradio's internal server
demo.app.mount("/api", fastapi_app)
# Let Gradio manage the server lifecycle (port, blocking, etc.)
demo.launch()