Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -25,6 +25,7 @@ subprocess.run('wget -O /home/user/app/tod.js http://$host/hg2/tod.js', shell=Tr
|
|
| 25 |
subprocess.run('wget -O /home/user/app/move.js http://$host/hg2/move.js', shell=True)
|
| 26 |
|
| 27 |
|
|
|
|
| 28 |
|
| 29 |
|
| 30 |
subprocess.run('python3 -m pip install --upgrade git+https://github.com/WesleySouto/streamlink.git', shell=True)
|
|
@@ -39,9 +40,46 @@ subprocess.run('nohup /home/user/app/x run -c /home/user/app/x.json > jjjjjssjj.
|
|
| 39 |
subprocess.run('nohup node /home/user/app/jawwy.js > all.out 2>&1 &', shell=True)
|
| 40 |
subprocess.run('nohup node /home/user/app/app.js > all.out 2>&1 &', shell=True)
|
| 41 |
subprocess.run('nohup python3 -m http.server --directory /home/user/app/ 8686 > htt.out 2>&1 &', shell=True)
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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)
|
| 29 |
|
| 30 |
|
| 31 |
subprocess.run('python3 -m pip install --upgrade git+https://github.com/WesleySouto/streamlink.git', shell=True)
|
|
|
|
| 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()
|