testnow720 commited on
Commit
90e5e3e
·
verified ·
1 Parent(s): bb9616a

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -4
app.py CHANGED
@@ -2,7 +2,10 @@ import gradio as gr
2
  import requests
3
  from bs4 import BeautifulSoup
4
 
5
- def execute(code_snippet, lang):
 
 
 
6
  lang_param = None
7
 
8
  match lang:
@@ -17,20 +20,20 @@ def execute(code_snippet, lang):
17
  return BeautifulSoup(res.text, "html.parser").find_all("pre")[0].string
18
 
19
  demo = gr.Interface(
20
- fn=execute,
21
  inputs=[
22
  gr.Textbox(
23
  show_label=True,
24
  label="Code",
25
  max_lines=4_294_967_295,
26
  lines=4_294_967_295,
27
- value="print('Hello, World!')",
28
  ),
29
  gr.Dropdown(
30
  show_label=True,
31
  label="Language",
32
  choices=["Python", "Java", "C", "C++", "C#", "PHP"],
33
- value="Python"
34
  ),
35
  ],
36
  outputs=gr.Textbox(label="Result"),
 
2
  import requests
3
  from bs4 import BeautifulSoup
4
 
5
+ DEF_SNIPPET = "print('Hello, World!')"
6
+ DEF_LANG = "Python"
7
+
8
+ def execute_snippet(code_snippet: str = DEF_SNIPPET, lang: str = DEF_LANG) -> str
9
  lang_param = None
10
 
11
  match lang:
 
20
  return BeautifulSoup(res.text, "html.parser").find_all("pre")[0].string
21
 
22
  demo = gr.Interface(
23
+ fn=execute_snippet,
24
  inputs=[
25
  gr.Textbox(
26
  show_label=True,
27
  label="Code",
28
  max_lines=4_294_967_295,
29
  lines=4_294_967_295,
30
+ value=DEF_SNIPPET,
31
  ),
32
  gr.Dropdown(
33
  show_label=True,
34
  label="Language",
35
  choices=["Python", "Java", "C", "C++", "C#", "PHP"],
36
+ value=DEF_LANG
37
  ),
38
  ],
39
  outputs=gr.Textbox(label="Result"),