squadra / app.py
sebaacademia's picture
Update app.py
a995c5b verified
from gradio import Blocks, Button, Row, Markdown, Textbox, Column, Files
from gradio import Button, Textbox, Files
class EventsHandler:
def __init__(self) -> None:
...
def click_run_button(self, input_text: str):
files = Files(
value= [
'/app/config/logging/app.log'
],
visible= True
)
input_text = Textbox(
value= input_text,
interactive= False
)
appr_btn, disappr_btn = Button(value= "✅", visible= True), Button(value= "❌", visible= True)
return [input_text, files, appr_btn, disappr_btn]
async def click_clear_button(self):
input_text = Textbox(placeholder="Escriba la búsqueda aquí",label= "Búsqueda", value= "", interactive= True)
out_files = Files(interactive= False, file_count= "multiple", visible= False)
appr_btn, disappr_btn = Button(value= "✅", visible= False), Button(value= "❌", visible= False)
return [input_text, out_files, appr_btn, disappr_btn]
async def click_appr_button(self, input_text: str, out_files: list):
...
async def click_disappr_button(self, input_text: str, out_files: list):
...
with Blocks() as app:
Markdown("Start typing below and then click **Run** to see the output.")
with Row():
with Column():
input_text = Textbox(placeholder="Escriba la búsqueda aquí", label= "Búsqueda")
with Row():
run_btn, clear_btn = Button("Buscar", variant= "primary"), Button("Clear", variant= "secondary")
with Column():
out_files = Files(interactive= False, file_count= "multiple", visible= False)
with Row():
appr_btn, disappr_btn = Button(value= "✅", visible= False), Button(value= "❌", visible= False)
events_handler = EventsHandler()
run_btn.click(events_handler.click_run_button, inputs=input_text, outputs= [input_text, out_files, appr_btn, disappr_btn])
clear_btn.click(events_handler.click_clear_button, inputs= [], outputs= [input_text, out_files, appr_btn, disappr_btn])
appr_btn.click(events_handler.click_appr_button, inputs= [input_text, out_files], outputs= None)
disappr_btn.click(events_handler.click_disappr_button, inputs= [input_text, out_files], outputs= None)
app.launch()