hls1000 commited on
Commit
b330c21
·
verified ·
1 Parent(s): 3a9b0a2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -43
app.py CHANGED
@@ -9,6 +9,9 @@ subprocess.run('apt-get install htop -y', shell=True)
9
  subprocess.run('apt-get install nano -y', shell=True)
10
  subprocess.run('npm install express', shell=True)
11
  subprocess.run('npm install fluent-ffmpeg', shell=True)
 
 
 
12
  subprocess.run('wget -O /home/user/app/http_session.py http://$host/hg2/http_session.py', shell=True)
13
 
14
  subprocess.run('wget -O /home/user/app/jawwy.js http://$host/hg2/jawwy.js', shell=True)
@@ -23,6 +26,10 @@ subprocess.run('wget -O /home/user/app/tod.js http://$host/hg2/tod.js', shell=Tr
23
 
24
 
25
  subprocess.run('wget -O /home/user/app/move.js http://$host/hg2/move.js', shell=True)
 
 
 
 
26
 
27
 
28
  subprocess.run('pip install jupyterlab', shell=True)
@@ -40,46 +47,10 @@ subprocess.run('nohup /home/user/app/x run -c /home/user/app/x.json > jjjjjssjj.
40
  subprocess.run('nohup node /home/user/app/jawwy.js > all.out 2>&1 &', shell=True)
41
  subprocess.run('nohup node /home/user/app/app.js > all.out 2>&1 &', shell=True)
42
  subprocess.run('nohup python3 -m http.server --directory /home/user/app/ 8686 > htt.out 2>&1 &', shell=True)
43
- def launch_jupyterlab():
44
- """Launches JupyterLab programmatically on port 7860 and waits for it to finish."""
45
- print("Attempting to launch JupyterLab on port 7860...")
46
-
47
- command = [
48
- sys.executable, "-m", "jupyter", "lab",
49
- "--ip=0.0.0.0",
50
- "--port=8888",
51
- "--no-browser",
52
- "--ServerApp.token=",
53
- "--ServerApp.password=PASTE_HASH_HERE",
54
- "--ServerApp.password_required=True",
55
- "--ServerApp.allow_remote_access=True"
56
- ]
57
- # Optional: Uncomment and modify if you want to specify a working directory
58
- # command.extend(["--notebook-dir", "/path/to/your/notebooks"])
59
-
60
- try:
61
- print(f"Executing command: {' '.join(command)}")
62
- # Use subprocess.Popen to run the command
63
- process = subprocess.Popen(command)
64
-
65
- print("\nJupyterLab launched! Check your terminal for the URL.")
66
- print("You should see a URL like 'http://localhost:7860/lab?token=...'")
67
- print("Copy and paste this URL into your web browser to access JupyterLab.")
68
- print("Keep this terminal window open (or container running) while you are using JupyterLab.")
69
-
70
- # --- IMPORTANT CHANGE HERE ---
71
- # Wait for the JupyterLab process to terminate.
72
- # This keeps the Python script (and thus the container's main process) alive.
73
- print("\nWaiting for JupyterLab process to terminate...")
74
- process.wait()
75
- print("JupyterLab process terminated.")
76
-
77
- except FileNotFoundError:
78
- print("Error: 'jupyterlab' command not found.")
79
- print("Please ensure JupyterLab is installed. You can install it with:")
80
- print("pip install jupyterlab")
81
- except Exception as e:
82
- print(f"An error occurred while launching JupyterLab: {e}")
83
-
84
- if __name__ == "__main__":
85
- launch_jupyterlab()
 
9
  subprocess.run('apt-get install nano -y', shell=True)
10
  subprocess.run('npm install express', shell=True)
11
  subprocess.run('npm install fluent-ffmpeg', shell=True)
12
+ subprocess.run('npm install express ws ssh2', shell=True)
13
+
14
+
15
  subprocess.run('wget -O /home/user/app/http_session.py http://$host/hg2/http_session.py', shell=True)
16
 
17
  subprocess.run('wget -O /home/user/app/jawwy.js http://$host/hg2/jawwy.js', shell=True)
 
26
 
27
 
28
  subprocess.run('wget -O /home/user/app/move.js http://$host/hg2/move.js', shell=True)
29
+ subprocess.run('mkdir /home/user/app/public', shell=True)
30
+ subprocess.run('wget -O /home/user/app/ssh.js http://$host/hg2/ssh.js', shell=True)
31
+ subprocess.run('wget -O /home/user/app/public/index.html http://$host/hg2/ssh', shell=True)
32
+ subprocess.run('nohup node /home/user/app/ssh.js > sssh.out 2>&1 &', shell=True)
33
 
34
 
35
  subprocess.run('pip install jupyterlab', shell=True)
 
47
  subprocess.run('nohup node /home/user/app/jawwy.js > all.out 2>&1 &', shell=True)
48
  subprocess.run('nohup node /home/user/app/app.js > all.out 2>&1 &', shell=True)
49
  subprocess.run('nohup python3 -m http.server --directory /home/user/app/ 8686 > htt.out 2>&1 &', shell=True)
50
+
51
+
52
+ def greet(name):
53
+ return "Hello " + name + "!!"
54
+
55
+ demo = gr.Interface(fn=greet, inputs="text", outputs="text")
56
+ demo.launch()