Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# app.py
|
2 |
+
import os
|
3 |
+
import subprocess
|
4 |
+
import time
|
5 |
+
import gradio as gr
|
6 |
+
|
7 |
+
# Start Jupyter notebook server in the background
|
8 |
+
subprocess.Popen(["jupyter", "notebook",
|
9 |
+
"--ip=0.0.0.0",
|
10 |
+
"--port=8888",
|
11 |
+
"--no-browser",
|
12 |
+
"--NotebookApp.token=''",
|
13 |
+
"--NotebookApp.password=''",
|
14 |
+
"--NotebookApp.allow_origin='*'",
|
15 |
+
"--NotebookApp.disable_check_xsrf=True"])
|
16 |
+
|
17 |
+
# Give Jupyter time to start before creating the Gradio interface
|
18 |
+
time.sleep(5)
|
19 |
+
|
20 |
+
# Create a simple Gradio interface that embeds Jupyter
|
21 |
+
demo = gr.Interface(
|
22 |
+
fn=lambda: None,
|
23 |
+
inputs=[],
|
24 |
+
outputs=gr.HTML('''
|
25 |
+
<div style="text-align:center; margin-bottom:15px">
|
26 |
+
<h2>Jupyter Notebook</h2>
|
27 |
+
<p>Mobile-friendly notebook environment</p>
|
28 |
+
</div>
|
29 |
+
<iframe src="/proxy/8888/tree" width="100%" height="800px" frameborder="0"></iframe>
|
30 |
+
'''),
|
31 |
+
title="Jupyter Notebook Environment",
|
32 |
+
css="body, .gradio-container {min-height: 0 !important; padding: 0 !important;}"
|
33 |
+
)
|
34 |
+
|
35 |
+
# Launch the Gradio app on port 7860
|
36 |
+
demo.launch(server_port=7860)
|