Spaces:
Paused
Paused
chaged
Browse files
app.py
CHANGED
|
@@ -1,7 +1,33 @@
|
|
| 1 |
-
|
|
|
|
| 2 |
|
| 3 |
-
|
| 4 |
-
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Filename: /home/user/app/app.py
|
| 2 |
+
# Version: 1691068773 (Unix timestamp at creation moment)
|
| 3 |
|
| 4 |
+
import os
|
| 5 |
+
import subprocess
|
| 6 |
|
| 7 |
+
def install_packages():
|
| 8 |
+
# Install necessary packages
|
| 9 |
+
subprocess.run(['pip3', 'install', 'jupyterlab'], check=True)
|
| 10 |
+
|
| 11 |
+
def configure_jupyter():
|
| 12 |
+
# Generate Jupyter configuration
|
| 13 |
+
jupyter_config_dir = os.path.expanduser('~/.jupyter')
|
| 14 |
+
os.makedirs(jupyter_config_dir, exist_ok=True)
|
| 15 |
+
|
| 16 |
+
config_file = os.path.join(jupyter_config_dir, 'jupyter_lab_config.py')
|
| 17 |
+
with open(config_file, 'w') as f:
|
| 18 |
+
f.write(f"""
|
| 19 |
+
c.ServerApp.ip = '0.0.0.0'
|
| 20 |
+
c.ServerApp.port = 7860
|
| 21 |
+
c.ServerApp.open_browser = False
|
| 22 |
+
c.ServerApp.password = u'sha1:2a38a4a931bdff5c7a5ca1c929ecf83a44a685d5:ef7fce5b72680b2c6e1098e5af2c71edc7d2cd6f' # Password "master333!"
|
| 23 |
+
c.ServerApp.root_dir = '/home/user/app'
|
| 24 |
+
""")
|
| 25 |
+
|
| 26 |
+
def start_jupyter():
|
| 27 |
+
# Start JupyterLab
|
| 28 |
+
subprocess.run(['jupyter-lab --autoreload'])
|
| 29 |
+
|
| 30 |
+
if __name__ == "__main__":
|
| 31 |
+
install_packages()
|
| 32 |
+
configure_jupyter()
|
| 33 |
+
start_jupyter()
|