Sugamdeol commited on
Commit
7c02e3b
·
verified ·
1 Parent(s): 69583a0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -11
app.py CHANGED
@@ -25,16 +25,8 @@ def execute_code_and_get_plot(code):
25
  except Exception as e:
26
  return None, f"Error: {str(e)}"
27
 
28
- # Define the Gradio interface
29
- interface = gr.Interface(
30
- fn=execute_code_and_get_plot,
31
- inputs=[
32
- gr.Code(
33
- label="Python Code",
34
- language="python",
35
- lines=20,
36
- placeholder="""
37
- # Example:
38
  import matplotlib.pyplot as plt
39
  import numpy as np
40
 
@@ -48,6 +40,15 @@ plt.xlabel('x')
48
  plt.ylabel('sin(x)')
49
  plt.grid(True)
50
  """
 
 
 
 
 
 
 
 
 
51
  )
52
  ],
53
  outputs=[
@@ -55,7 +56,8 @@ plt.grid(True)
55
  gr.Textbox(label="Output Message")
56
  ],
57
  title="Python Code to Matplotlib Plot Generator",
58
- description="Enter Python code that generates a matplotlib plot. The plot will be displayed as an image."
 
59
  )
60
 
61
  if __name__ == "__main__":
 
25
  except Exception as e:
26
  return None, f"Error: {str(e)}"
27
 
28
+ # Example code
29
+ example_code = """
 
 
 
 
 
 
 
 
30
  import matplotlib.pyplot as plt
31
  import numpy as np
32
 
 
40
  plt.ylabel('sin(x)')
41
  plt.grid(True)
42
  """
43
+
44
+ # Define the Gradio interface
45
+ interface = gr.Interface(
46
+ fn=execute_code_and_get_plot,
47
+ inputs=[
48
+ gr.Code(
49
+ label="Python Code",
50
+ language="python",
51
+ lines=20,
52
  )
53
  ],
54
  outputs=[
 
56
  gr.Textbox(label="Output Message")
57
  ],
58
  title="Python Code to Matplotlib Plot Generator",
59
+ description="Enter Python code that generates a matplotlib plot. The plot will be displayed as an image.",
60
+ examples=[[example_code]],
61
  )
62
 
63
  if __name__ == "__main__":