File size: 1,158 Bytes
c9a5d92
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c1a4d47
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
35
36
37
# 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)