hobs commited on
Commit
bf32265
·
1 Parent(s): ea86819

no __main__

Browse files
Files changed (1) hide show
  1. app.py +45 -47
app.py CHANGED
@@ -103,50 +103,48 @@ def get_types(cls_set: List[Type], component: str):
103
  return docset, types
104
 
105
 
106
- if __name__ == '__main__':
107
-
108
- routes.get_types = get_types
109
-
110
- with gr.Blocks() as html_block:
111
- gr.Markdown("# Gradio Blocks (3.0) with REST API")
112
- textbox_input = gr.Textbox(
113
- value="forty-two",
114
- label="Input number words:",
115
- )
116
- button_text2int = gr.Button("text2int")
117
- button_text2int_preprocessed = gr.Button("text2int with preprocessing")
118
- textbox_output = gr.Textbox(
119
- value="42",
120
- label="Output integer:"
121
- )
122
- button_text2int.click(text2int, inputs=[textbox_input], outputs=[textbox_output])
123
- button_text2int_preprocessed.click(text2int_preprocessed, inputs=[textbox_input], outputs=[textbox_output])
124
- gr.Markdown(r"""
125
-
126
- ## API
127
-
128
- You can select which function to run using the `fn_index` argument:
129
-
130
- ```python
131
- import requests
132
-
133
- requests.post(
134
- url="https://Hobson-gradio-rest-api.hf.space/api/predict/", json={"data": ["one hundred forty-two"], "fn_index": 0}
135
- ).json()
136
- ```
137
-
138
- Or using `curl`:
139
-
140
- ```bash
141
- curl -X POST https://Hobson-gradio-rest-api.hf.space/api/predict/ -H 'Content-Type: application/json' -d '{"data": ["one hundred forty-two"], "fn_index": 0}'
142
- ```
143
- """)
144
-
145
- interface = gr.Interface(lambda: None, inputs=[textbox_input], outputs=[textbox_output])
146
-
147
- html_block.input_components = interface.input_components
148
- html_block.output_components = interface.output_components
149
- html_block.examples = None
150
- html_block.predict_durations = []
151
-
152
- bapp = html_block.launch(share=True)
 
103
  return docset, types
104
 
105
 
106
+ routes.get_types = get_types
107
+
108
+ with gr.Blocks() as html_block:
109
+ gr.Markdown("# Gradio Blocks (3.0) with REST API")
110
+ textbox_input = gr.Textbox(
111
+ value="forty-two",
112
+ label="Input number words:",
113
+ )
114
+ button_text2int = gr.Button("text2int")
115
+ button_text2int_preprocessed = gr.Button("text2int with preprocessing")
116
+ textbox_output = gr.Textbox(
117
+ value="42",
118
+ label="Output integer:"
119
+ )
120
+ button_text2int.click(text2int, inputs=[textbox_input], outputs=[textbox_output])
121
+ button_text2int_preprocessed.click(text2int_preprocessed, inputs=[textbox_input], outputs=[textbox_output])
122
+ gr.Markdown(r"""
123
+
124
+ ## API
125
+
126
+ You can select which function to run using the `fn_index` argument:
127
+
128
+ ```python
129
+ import requests
130
+
131
+ requests.post(
132
+ url="https://Hobson-gradio-rest-api.hf.space/api/predict/", json={"data": ["one hundred forty-two"], "fn_index": 0}
133
+ ).json()
134
+ ```
135
+
136
+ Or using `curl`:
137
+
138
+ ```bash
139
+ curl -X POST https://Hobson-gradio-rest-api.hf.space/api/predict/ -H 'Content-Type: application/json' -d '{"data": ["one hundred forty-two"], "fn_index": 0}'
140
+ ```
141
+ """)
142
+
143
+ interface = gr.Interface(lambda: None, inputs=[textbox_input], outputs=[textbox_output])
144
+
145
+ html_block.input_components = interface.input_components
146
+ html_block.output_components = interface.output_components
147
+ html_block.examples = None
148
+ html_block.predict_durations = []
149
+
150
+ bapp = html_block.launch(share=True)