Code-agent-v1 / app.py
nakas's picture
Update app.py
c1a4d47 verified
# app.py
import os
import subprocess
import time
import gradio as gr
# Start Jupyter notebook server in the background
subprocess.Popen(["jupyter", "notebook",
"--ip=0.0.0.0",
"--port=8888",
"--no-browser",
"--NotebookApp.token=''",
"--NotebookApp.password=''",
"--NotebookApp.allow_origin='*'",
"--NotebookApp.disable_check_xsrf=True"])
# Give Jupyter time to start before creating the Gradio interface
time.sleep(5)
# Create a simple Gradio interface that embeds Jupyter
demo = gr.Interface(
fn=lambda: None,
inputs=[],
outputs=gr.HTML('''
<div style="text-align:center; margin-bottom:15px">
<h2>Jupyter Notebook</h2>
<p>Mobile-friendly notebook environment</p>
</div>
<iframe src="/proxy/8888/tree" width="100%" height="800px" frameborder="0"></iframe>
'''),
title="Jupyter Notebook Environment",
css="body, .gradio-container {min-height: 0 !important; padding: 0 !important;}"
)
# Launch the Gradio app on port 7860
demo.launch(server_port=7860)