Spaces:
Paused
Paused
# 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() | |