Spaces:
Sleeping
Sleeping
sebaacademia
commited on
Commit
•
f4748ec
1
Parent(s):
cf2f7be
Upload 2 files
Browse files- app.py +21 -5
- controller.py +39 -0
app.py
CHANGED
@@ -1,7 +1,23 @@
|
|
1 |
-
|
|
|
|
|
2 |
|
3 |
-
|
4 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
5 |
|
6 |
-
|
7 |
-
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from config.logging import STREAM_LOGGER
|
2 |
+
from src.controller import EventsHandler
|
3 |
+
from gradio import Blocks, Button, Row, Markdown, Textbox, Column, Files
|
4 |
|
5 |
+
with Blocks() as demo:
|
6 |
+
Markdown("Start typing below and then click **Run** to see the output.")
|
7 |
+
with Row():
|
8 |
+
with Column():
|
9 |
+
input_text = Textbox(placeholder="Escriba la búsqueda aquí", label= "Búsqueda")
|
10 |
+
with Row():
|
11 |
+
run_btn, clear_btn = Button("Buscar", variant= "primary"), Button("Clear", variant= "secondary")
|
12 |
+
with Column():
|
13 |
+
out_files = Files(interactive= False, file_count= "multiple", visible= False)
|
14 |
+
with Row():
|
15 |
+
appr_btn, disappr_btn = Button(value= "✅", visible= False), Button(value= "❌", visible= False)
|
16 |
|
17 |
+
events_handler = EventsHandler()
|
18 |
+
|
19 |
+
run_btn.click(events_handler.click_run_button, inputs=input_text, outputs= [input_text, out_files, appr_btn, disappr_btn])
|
20 |
+
clear_btn.click(events_handler.click_clear_button, inputs= [], outputs= [input_text, out_files, appr_btn, disappr_btn])
|
21 |
+
appr_btn.click(events_handler.click_appr_button, inputs= [input_text, out_files], outputs= None)
|
22 |
+
disappr_btn.click(events_handler.click_disappr_button, inputs= [input_text, out_files], outputs= None)
|
23 |
+
|
controller.py
ADDED
@@ -0,0 +1,39 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from config.logging import STREAM_LOGGER
|
2 |
+
from gradio import Button, Textbox, Files
|
3 |
+
|
4 |
+
|
5 |
+
class EventsHandler:
|
6 |
+
def __init__(self) -> None:
|
7 |
+
...
|
8 |
+
|
9 |
+
def click_run_button(self, input_text: str):
|
10 |
+
STREAM_LOGGER.debug("click on run button")
|
11 |
+
files = Files(
|
12 |
+
value= [
|
13 |
+
'/app/config/logging/app.log'
|
14 |
+
],
|
15 |
+
visible= True
|
16 |
+
)
|
17 |
+
input_text = Textbox(
|
18 |
+
value= input_text,
|
19 |
+
interactive= False
|
20 |
+
)
|
21 |
+
appr_btn, disappr_btn = Button(value= "✅", visible= True), Button(value= "❌", visible= True)
|
22 |
+
return [input_text, files, appr_btn, disappr_btn]
|
23 |
+
|
24 |
+
async def click_clear_button(self):
|
25 |
+
STREAM_LOGGER.debug("click on clear button")
|
26 |
+
|
27 |
+
input_text = Textbox(placeholder="Escriba la búsqueda aquí",label= "Búsqueda", value= "", interactive= True)
|
28 |
+
out_files = Files(interactive= False, file_count= "multiple", visible= False)
|
29 |
+
appr_btn, disappr_btn = Button(value= "✅", visible= False), Button(value= "❌", visible= False)
|
30 |
+
|
31 |
+
return [input_text, out_files, appr_btn, disappr_btn]
|
32 |
+
|
33 |
+
async def click_appr_button(self, input_text: str, out_files: list):
|
34 |
+
STREAM_LOGGER.debug("click on approve button")
|
35 |
+
...
|
36 |
+
|
37 |
+
async def click_disappr_button(self, input_text: str, out_files: list):
|
38 |
+
STREAM_LOGGER.debug("click on disapprove button")
|
39 |
+
...
|