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