Spaces:
Runtime error
Runtime error
import gradio as gr | |
mf={ | |
"Heading1":"# $INP", | |
"Heading2":"## $INP", | |
"Heading3":"### $INP", | |
"Bold":"**$INP**" | |
} | |
def upd(inp,cur_l,cur_d,format): | |
if not cur_l: | |
cur_l=[] | |
if not cur_d: | |
cur_d={} | |
#for ea in list(cur.keys()): | |
line=f'{mf[format].replace("$INP",inp)}' | |
cur_l.append(line) | |
out_str="" | |
for ea in cur_l: | |
out_str+=ea | |
return out_str,cur_l,out_str | |
with gr.Blocks() as app: | |
cur_l=gr.State() | |
cur_d=gr.State() | |
prev=gr.Markdown("") | |
format=gr.Dropdown(label="Line Format",choices=[m for m in list(mf.keys())]) | |
txt=gr.Textbox(lines=20) | |
btn=gr.Button() | |
out_txt=gr.Textbox() | |
btn.click(upd,[txt,cur_l,cur_d,format],[prev,cur_l,out_txt]) | |
app.launch() |