e1732a364fed commited on
Commit
d802802
·
1 Parent(s): 5712cc4

use Blocks

Browse files
Files changed (1) hide show
  1. app.py +34 -29
app.py CHANGED
@@ -103,34 +103,39 @@ def predict_by_text(head, body):
103
  return h_result, b_result
104
 
105
 
106
- demo = gr.Interface(
107
- fn=predict_by_text,
108
- inputs=[
109
- gr.Textbox(
110
- label="Head",
111
- info="http response head",
112
- lines=6,
113
- max_lines=10000,
114
- value="200 OK",
115
- ),
116
- gr.Textbox(
117
- label="Body",
118
- info="http response body",
119
- lines=6,
120
- max_lines=10000000000,
121
- value="<body>The quick brown fox jumped over the lazy dogs.</body>",
122
- ),
123
- ],
124
- outputs=[
125
- gr.Textbox(
126
- label="Head",
127
- info="http response prediction",
128
- ),
129
- gr.Textbox(
130
- label="Body",
131
- info="http response prediction",
132
- ),
133
- ],
134
- )
 
 
 
 
 
135
 
136
  demo.launch()
 
103
  return h_result, b_result
104
 
105
 
106
+ with gr.Blocks() as demo:
107
+ btn = gr.Button("Classify")
108
+
109
+ @btn.click(
110
+ inputs=[
111
+ gr.Textbox(
112
+ label="Head",
113
+ info="http response head",
114
+ lines=6,
115
+ max_lines=10000,
116
+ value="200 OK",
117
+ ),
118
+ gr.Textbox(
119
+ label="Body",
120
+ info="http response body",
121
+ lines=6,
122
+ max_lines=10000000000,
123
+ value="<body>The quick brown fox jumped over the lazy dogs.</body>",
124
+ ),
125
+ ],
126
+ outputs=[
127
+ gr.Textbox(
128
+ label="Head",
129
+ info="http response prediction",
130
+ ),
131
+ gr.Textbox(
132
+ label="Body",
133
+ info="http response prediction",
134
+ ),
135
+ ],
136
+ )
137
+ def f(h, b):
138
+ return predict_by_text(h, b)
139
+
140
 
141
  demo.launch()