File size: 397 Bytes
3b01b0f
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import gradio as gr
import nbformat
from nbconvert import PythonExporter
import subprocess

def run_notebook():
    with open("app.ipynb") as f:
        notebook = nbformat.read(f, as_version=4)
    python_script, _ = PythonExporter().from_notebook_node(notebook)
    with open("app_temp.py", "w") as f:
        f.write(python_script)
    subprocess.run(["python", "app_temp.py"])

run_notebook()