Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
@@ -1,5 +1,6 @@
|
|
1 |
import gradio as gr
|
2 |
import pulp
|
|
|
3 |
|
4 |
demo = gr.Blocks()
|
5 |
|
@@ -16,6 +17,10 @@ def fx2(x,y):
|
|
16 |
resu={'data':[x[i] for i in range(len(t)) if pulp.value(t[i])]}
|
17 |
return resu
|
18 |
|
|
|
|
|
|
|
|
|
19 |
with demo:
|
20 |
gr.Markdown(
|
21 |
"""
|
@@ -31,8 +36,13 @@ with demo:
|
|
31 |
val_input = [gr.Textbox(placeholder='请输入凑数序列,如"1,3,5,10,16,54,32,48,6,7"',label="请输入待凑数序列",show_label=True),gr.Number(value=80,label="请输入凑数和值",show_label=True)]
|
32 |
json_output = gr.JSON(label="输出运算结果",show_label=True)
|
33 |
cs_button = gr.Button("开始凑数>>")
|
|
|
|
|
|
|
|
|
34 |
|
35 |
tj_button.click(fx1, inputs=text_input, outputs=text_output)
|
36 |
cs_button.click(fx2, inputs=val_input, outputs=json_output)
|
|
|
37 |
|
38 |
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import pulp
|
3 |
+
import pandas as pd
|
4 |
|
5 |
demo = gr.Blocks()
|
6 |
|
|
|
17 |
resu={'data':[x[i] for i in range(len(t)) if pulp.value(t[i])]}
|
18 |
return resu
|
19 |
|
20 |
+
def fx3(x):
|
21 |
+
df=pd.read_excel(x,header=0)
|
22 |
+
return df
|
23 |
+
|
24 |
with demo:
|
25 |
gr.Markdown(
|
26 |
"""
|
|
|
36 |
val_input = [gr.Textbox(placeholder='请输入凑数序列,如"1,3,5,10,16,54,32,48,6,7"',label="请输入待凑数序列",show_label=True),gr.Number(value=80,label="请输入凑数和值",show_label=True)]
|
37 |
json_output = gr.JSON(label="输出运算结果",show_label=True)
|
38 |
cs_button = gr.Button("开始凑数>>")
|
39 |
+
with gr.TabItem("文件交互"):
|
40 |
+
file_input = gr.File(file_count="single",label="请选择需要读取的excel文件",show_label=True)
|
41 |
+
table_output = gr.Dataframe(label="输出读取的表格数据",show_label=True)
|
42 |
+
dq_button = gr.Button("开始读取>>")
|
43 |
|
44 |
tj_button.click(fx1, inputs=text_input, outputs=text_output)
|
45 |
cs_button.click(fx2, inputs=val_input, outputs=json_output)
|
46 |
+
dq_button.click(fx3, inputs=file_input, outputs=table_output)
|
47 |
|
48 |
demo.launch()
|