Update app.py
Browse files
app.py
CHANGED
|
@@ -1,71 +1,38 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import subprocess
|
| 3 |
-
import threading
|
| 4 |
-
|
| 5 |
import gradio as gr
|
| 6 |
import spaces
|
| 7 |
-
import httpx
|
| 8 |
-
from fastapi import FastAPI, Request
|
| 9 |
-
from fastapi.responses import Response
|
| 10 |
-
from gradio.routes import mount_gradio_app
|
| 11 |
-
|
| 12 |
-
node = None
|
| 13 |
-
|
| 14 |
-
def start_node():
|
| 15 |
-
global node
|
| 16 |
-
|
| 17 |
-
if node and node.poll() is None:
|
| 18 |
-
return "Already running"
|
| 19 |
-
|
| 20 |
-
node = subprocess.Popen(
|
| 21 |
-
["node", "server.js"],
|
| 22 |
-
cwd="/home/user/app"
|
| 23 |
-
)
|
| 24 |
-
|
| 25 |
-
return "Started"
|
| 26 |
-
|
| 27 |
-
# Başlangıçta Node'u çalıştır
|
| 28 |
-
threading.Thread(target=start_node, daemon=True).start()
|
| 29 |
|
| 30 |
-
# ZeroGPU için boş GPU fonksiyonu
|
| 31 |
@spaces.GPU
|
| 32 |
def dummy():
|
| 33 |
return "ok"
|
| 34 |
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
)
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
# FastAPI içine mount et
|
| 67 |
-
app = mount_gradio_app(app, demo, path="/")
|
| 68 |
-
|
| 69 |
-
# Gradio'yu başlat
|
| 70 |
-
if __name__ == "__main__":
|
| 71 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
import spaces
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 3 |
|
|
|
|
| 4 |
@spaces.GPU
|
| 5 |
def dummy():
|
| 6 |
return "ok"
|
| 7 |
|
| 8 |
+
with gr.Blocks() as demo:
|
| 9 |
+
gr.Markdown("# Debug")
|
| 10 |
+
|
| 11 |
+
print("=" * 60)
|
| 12 |
+
print("GRADIO VERSION:", gr.__version__)
|
| 13 |
+
print("DEMO TYPE:", type(demo))
|
| 14 |
+
print("DEMO DIR:")
|
| 15 |
+
print(dir(demo))
|
| 16 |
+
|
| 17 |
+
for name in [
|
| 18 |
+
"app",
|
| 19 |
+
"fastapi_app",
|
| 20 |
+
"server_app",
|
| 21 |
+
"_app",
|
| 22 |
+
"_server_app",
|
| 23 |
+
"routes",
|
| 24 |
+
]:
|
| 25 |
+
print(f"\n{name}:")
|
| 26 |
+
if hasattr(demo, name):
|
| 27 |
+
obj = getattr(demo, name)
|
| 28 |
+
print(type(obj))
|
| 29 |
+
try:
|
| 30 |
+
print(dir(obj))
|
| 31 |
+
except Exception as e:
|
| 32 |
+
print(e)
|
| 33 |
+
else:
|
| 34 |
+
print("NOT FOUND")
|
| 35 |
+
|
| 36 |
+
print("=" * 60)
|
| 37 |
+
|
| 38 |
+
demo.launch(server_name="0.0.0.0", server_port=7860, ssr_mode=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|