Spaces:
Runtime error
Runtime error
acumplid
commited on
Commit
·
002659d
1
Parent(s):
ec4e0ff
Made functions named endpoints so can be consumed via api request
Browse files
app.py
CHANGED
@@ -102,10 +102,11 @@ with gr.Blocks(**AinaGradioTheme().get_kwargs()) as demo:
|
|
102 |
input_.change(
|
103 |
fn=check_max_characters,
|
104 |
inputs=[input_, placeholder_max_characters],
|
105 |
-
outputs=[clear_btn, submit_btn]
|
|
|
106 |
)
|
107 |
|
108 |
-
input_.change(fn=None, inputs=[input_, placeholder_max_characters],
|
109 |
document.getElementById('countertext').textContent = i.length > m && 'Max length ' + m + ' characters. ' || ''
|
110 |
document.getElementById('inputlenght').textContent = i.length + ' '
|
111 |
document.getElementById('inputlenght').style.color = (i.length > m) ? "#ef4444" : "";
|
@@ -115,15 +116,18 @@ with gr.Blocks(**AinaGradioTheme().get_kwargs()) as demo:
|
|
115 |
fn=clear,
|
116 |
inputs=[],
|
117 |
outputs=[input_, output],
|
118 |
-
queue=False
|
|
|
119 |
)
|
120 |
|
121 |
submit_btn.click(
|
122 |
fn=submit_input,
|
123 |
inputs=[input_],
|
124 |
-
outputs=[output]
|
|
|
|
|
125 |
)
|
126 |
|
127 |
if __name__ == "__main__":
|
128 |
-
demo.queue(
|
129 |
-
demo.launch(show_api=
|
|
|
102 |
input_.change(
|
103 |
fn=check_max_characters,
|
104 |
inputs=[input_, placeholder_max_characters],
|
105 |
+
outputs=[clear_btn, submit_btn],
|
106 |
+
api_name=False
|
107 |
)
|
108 |
|
109 |
+
input_.change(fn=None, inputs=[input_, placeholder_max_characters], js="""(i, m) => {
|
110 |
document.getElementById('countertext').textContent = i.length > m && 'Max length ' + m + ' characters. ' || ''
|
111 |
document.getElementById('inputlenght').textContent = i.length + ' '
|
112 |
document.getElementById('inputlenght').style.color = (i.length > m) ? "#ef4444" : "";
|
|
|
116 |
fn=clear,
|
117 |
inputs=[],
|
118 |
outputs=[input_, output],
|
119 |
+
queue=False,
|
120 |
+
api_name=False,
|
121 |
)
|
122 |
|
123 |
submit_btn.click(
|
124 |
fn=submit_input,
|
125 |
inputs=[input_],
|
126 |
+
outputs=[output],
|
127 |
+
concurrency_limit=1,
|
128 |
+
api_name="get-results"
|
129 |
)
|
130 |
|
131 |
if __name__ == "__main__":
|
132 |
+
demo.queue(api_open=False)
|
133 |
+
demo.launch(show_api=True)
|