Spaces:
Runtime error
Runtime error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
hist = ''
|
| 3 |
+
|
| 4 |
+
def combinar(nombre,mensaje):
|
| 5 |
+
global hist
|
| 6 |
+
mensaje = f'[{nombre}]: {mensaje}\n'
|
| 7 |
+
hist +=mensaje
|
| 8 |
+
return hist
|
| 9 |
+
|
| 10 |
+
def vaciar():
|
| 11 |
+
return ''
|
| 12 |
+
|
| 13 |
+
def contador():
|
| 14 |
+
global numero_contador
|
| 15 |
+
numero_contador += 1
|
| 16 |
+
return str(numero_contador)
|
| 17 |
+
|
| 18 |
+
with gr.Blocks() as app:
|
| 19 |
+
|
| 20 |
+
|
| 21 |
+
chat = gr.TextArea(value=hist,
|
| 22 |
+
interactive=False,
|
| 23 |
+
lines=6,
|
| 24 |
+
show_label=False,
|
| 25 |
+
max_lines=6)
|
| 26 |
+
|
| 27 |
+
with gr.Row():
|
| 28 |
+
with gr.Column(scale=0.3):
|
| 29 |
+
username = gr.Textbox(show_label=False,placeholder='Tu nickname')
|
| 30 |
+
with gr.Column(scale=1):
|
| 31 |
+
message = gr.Textbox(placeholder='Tu mensaje',show_label=False)
|
| 32 |
+
message.submit(fn=combinar,inputs=[username,message],outputs=chat)
|
| 33 |
+
message.submit(fn=vaciar,outputs=message)
|
| 34 |
+
|
| 35 |
+
|
| 36 |
+
boton = gr.Button('Enviar mensaje',live=True)
|
| 37 |
+
boton.click(fn=combinar,inputs=[username,message],outputs=chat)
|
| 38 |
+
boton.click(fn=vaciar,outputs=message)
|
| 39 |
+
|
| 40 |
+
|
| 41 |
+
app.launch(share=True,debug=True)
|