Spaces:
Running on Zero
Running on Zero
Noperi commited on
Commit ·
564b9a0
1
Parent(s): 25ffad4
Use synchronous function with @spaces.GPU for ZeroGPU compatibility
Browse files- app.py +5 -22
- requirements.txt +0 -2
app.py
CHANGED
|
@@ -1,28 +1,11 @@
|
|
| 1 |
-
import os
|
| 2 |
import gradio as gr
|
| 3 |
import spaces
|
| 4 |
-
from fastapi import FastAPI, HTTPException
|
| 5 |
-
import uvicorn
|
| 6 |
|
| 7 |
-
|
|
|
|
|
|
|
| 8 |
|
| 9 |
-
|
| 10 |
-
def root():
|
| 11 |
-
return {"status": "GitCloud Bridge Active"}
|
| 12 |
-
|
| 13 |
-
@app.get("/health")
|
| 14 |
-
def health():
|
| 15 |
-
return {"status": "healthy"}
|
| 16 |
-
|
| 17 |
-
@app.get("/download_tg")
|
| 18 |
-
async def download_telegram_file(file_id: str, bot_token: str, chat_id: str = None, repo: str = None, pat: str = None):
|
| 19 |
-
return {"status": "success", "file_id": file_id, "message": "Bridge endpoint working"}
|
| 20 |
-
|
| 21 |
-
def health_ui():
|
| 22 |
-
return "GitCloud Bridge Online"
|
| 23 |
-
|
| 24 |
-
demo = gr.Interface(fn=health_ui, inputs=[], outputs="text")
|
| 25 |
-
app = gr.mount_gradio_app(app, demo, path="/gradio")
|
| 26 |
|
| 27 |
if __name__ == "__main__":
|
| 28 |
-
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
|
|
|
|
|
|
| 3 |
|
| 4 |
+
@spaces.GPU
|
| 5 |
+
def download_telegram_file(file_id):
|
| 6 |
+
return "Bridge ready: " + file_id
|
| 7 |
|
| 8 |
+
demo = gr.Interface(fn=download_telegram_file, inputs="text", outputs="text")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
if __name__ == "__main__":
|
| 11 |
+
demo.launch()
|
requirements.txt
CHANGED
|
@@ -1,5 +1,3 @@
|
|
| 1 |
-
fastapi
|
| 2 |
-
uvicorn
|
| 3 |
gradio==4.19.0
|
| 4 |
huggingface_hub<0.24.0
|
| 5 |
spaces
|
|
|
|
|
|
|
|
|
|
| 1 |
gradio==4.19.0
|
| 2 |
huggingface_hub<0.24.0
|
| 3 |
spaces
|