Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -6,13 +6,24 @@ mf={
|
|
6 |
"Heading3":"### $INP",
|
7 |
"Bold":"**$INP**"
|
8 |
}
|
9 |
-
def upd(inp,format):
|
|
|
|
|
|
|
|
|
|
|
10 |
line=f'{mf[format].replace("$INP",inp)}'
|
11 |
-
|
|
|
|
|
|
|
|
|
12 |
with gr.Blocks() as app:
|
|
|
|
|
|
|
13 |
format=gr.Dropdown(label="Line Format",choices=[m for m in list(mf.keys())])
|
14 |
-
txt=gr.Textbox()
|
15 |
btn=gr.Button()
|
16 |
-
|
17 |
-
btn.click(upd,[txt,format],prev)
|
18 |
app.launch()
|
|
|
6 |
"Heading3":"### $INP",
|
7 |
"Bold":"**$INP**"
|
8 |
}
|
9 |
+
def upd(inp,cur_l,cur_d,format):
|
10 |
+
if not cur_l:
|
11 |
+
cur_l=[]
|
12 |
+
if not cur_d:
|
13 |
+
cur_d={}
|
14 |
+
#for ea in list(cur.keys()):
|
15 |
line=f'{mf[format].replace("$INP",inp)}'
|
16 |
+
cur_l.append(line)
|
17 |
+
out_str=""
|
18 |
+
for ea in cur_l:
|
19 |
+
out_str+=ea
|
20 |
+
return out_str,cur_l
|
21 |
with gr.Blocks() as app:
|
22 |
+
cur_l=gr.State()
|
23 |
+
cur_d=gr.State()
|
24 |
+
prev=gr.Markdown("")
|
25 |
format=gr.Dropdown(label="Line Format",choices=[m for m in list(mf.keys())])
|
26 |
+
txt=gr.Textbox(lines=20)
|
27 |
btn=gr.Button()
|
28 |
+
btn.click(upd,[txt,cur_l,curl_d,format],[prev,cur_l])
|
|
|
29 |
app.launch()
|