WACATW commited on
Commit
701c9ae
·
verified ·
1 Parent(s): fd8fdd3

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -46
app.py DELETED
@@ -1,46 +0,0 @@
1
- """Hugging Face Space 入口(SDK: Gradio + ZeroGPU,业务 FastAPI 挂载于 Gradio 的 ASGI 应用)
2
-
3
- ZeroGPU 平台强制要求:Space 启动时检测到 @spaces.GPU 装饰函数且调用
4
- demo.launch()。本文件按此要求提供占位 GPU 函数与 Gradio demo;真正
5
- 的业务(前端页面 + /api/*)由 FastAPI 应用 main.app 提供,挂载在
6
- Gradio 的底层 ASGI 应用(demo.app)上,并将根路径 / 指回云相机页面。
7
-
8
- _gpu_probe 仅为满足平台检测,业务从不调用,不消耗 GPU 免费配额。
9
- """
10
- import os
11
- from pathlib import Path
12
-
13
- import gradio as gr
14
- import spaces # noqa: F401 (ZeroGPU 镜像自带)
15
- from starlette.responses import FileResponse
16
- from starlette.routing import Route
17
-
18
- from main import app as cc_app
19
-
20
- INDEX = Path(__file__).parent / "index.html"
21
-
22
-
23
- @spaces.GPU
24
- def _gpu_probe(): # ZeroGPU 平台检测占位函数(业务不调用)
25
- return "ok"
26
-
27
-
28
- with gr.Blocks() as demo:
29
- gr.Markdown("云端相机")
30
-
31
- demo.queue()
32
-
33
-
34
- if __name__ == "__main__":
35
- demo.launch(prevent_thread_lock=True, quiet=True)
36
- fa = demo.app
37
- fa.mount("/", cc_app)
38
-
39
- async def _index(request):
40
- return FileResponse(INDEX)
41
-
42
- fa.router.routes.insert(0, Route("/", _index, methods=["GET"]))
43
-
44
- # 保持主线程存活,防止进程退出导致服务关闭
45
- import threading
46
- threading.Event().wait()