J Z commited on
Commit
ed00e83
·
verified ·
1 Parent(s): a28b77c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -61
app.py CHANGED
@@ -1,65 +1,14 @@
1
- import os
2
- import sys
3
- import subprocess
4
- import time
5
- import signal
6
- import atexit
7
 
8
- # Add the DarwinChatbot scripts directory to the Python path
9
- DARWIN_SCRIPTS_PATH = "/data/DarwinChatbot/scripts"
10
- NICEGUI_PORT = 7860
11
 
12
- # Path to Ollama executable
13
- OLLAMA_PATH = "/data/DarwinChatbot/ollama"
14
-
15
- # Global process variables
16
- OLLAMA_PROCESS = None
17
- DARWIN_APP_PROCESS = None
18
-
19
- def cleanup():
20
- """Stop all processes on exit"""
21
- if DARWIN_APP_PROCESS:
22
- DARWIN_APP_PROCESS.terminate()
23
-
24
- if OLLAMA_PROCESS:
25
- OLLAMA_PROCESS.terminate()
26
-
27
- # Register cleanup handler
28
- atexit.register(cleanup)
29
- signal.signal(signal.SIGTERM, lambda sig, frame: cleanup())
30
- signal.signal(signal.SIGINT, lambda sig, frame: cleanup())
31
 
32
  if __name__ == "__main__":
33
- # 1. Start Ollama server
34
- print("Starting Ollama server...")
35
- OLLAMA_PROCESS = subprocess.Popen(
36
- [OLLAMA_PATH, "serve"],
37
- stdout=subprocess.DEVNULL,
38
- stderr=subprocess.DEVNULL
39
- )
40
-
41
- # Give Ollama a moment to start
42
- time.sleep(3)
43
-
44
- # 2. Start the Darwin app
45
- print("Starting Darwin Avatar app...")
46
- env = os.environ.copy()
47
- env["NICEGUI_PORT"] = str(NICEGUI_PORT)
48
- env["NICEGUI_HOST"] = "0.0.0.0"
49
-
50
- os.chdir(DARWIN_SCRIPTS_PATH)
51
- DARWIN_APP_PROCESS = subprocess.Popen(
52
- [sys.executable, "app.py"],
53
- env=env,
54
- cwd=DARWIN_SCRIPTS_PATH
55
- )
56
-
57
- print(f"Darwin Avatar is running on port {NICEGUI_PORT}")
58
-
59
- # 3. Keep the main process running
60
- try:
61
- DARWIN_APP_PROCESS.wait()
62
- except KeyboardInterrupt:
63
- pass
64
- finally:
65
- cleanup()
 
1
+ import gradio as gr
 
 
 
 
 
2
 
3
+ def hello():
4
+ return "Space is running successfully!"
 
5
 
6
+ demo = gr.Interface(
7
+ fn=hello,
8
+ inputs=None,
9
+ outputs="text",
10
+ title="Minimal Gradio App"
11
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
12
 
13
  if __name__ == "__main__":
14
+ demo.launch()