research14 commited on
Commit
d901169
·
1 Parent(s): 1801662

testing html on gradio

Browse files
Files changed (1) hide show
  1. app.py +14 -6
app.py CHANGED
@@ -1,16 +1,24 @@
1
  import gradio as gr
 
2
 
3
- # Define a function that echoes the input text
4
  def echo_text(input_text):
5
  return input_text
6
 
 
 
 
 
 
 
 
 
 
 
 
7
  iface = gr.Interface(
8
  fn=echo_text,
9
- inputs=gr.Textbox(text="Enter text here...", label="Input Text"), # Text input field with a label
10
- outputs=gr.Row( # Create a row layout for input and output
11
- gr.Text(label="Input Text:", type="output"), # Display input text above output
12
- gr.Text(label="Output Text:", type="output"), # Display output text
13
- ),
14
  live=True
15
  )
16
 
 
1
  import gradio as gr
2
+ import random
3
 
 
4
  def echo_text(input_text):
5
  return input_text
6
 
7
+ # Custom HTML and CSS to display input above output
8
+ custom_interface = """
9
+ <div style="text-align: center;">
10
+ <label for="input-text">Input Text:</label><br>
11
+ <input type="text" id="input-text" name="input_text" value="Enter text here..." style="width: 80%;"><br>
12
+ <br>
13
+ <label for="output-text">Output Text:</label><br>
14
+ <textarea id="output-text" name="output_text" rows="5" cols="40" readonly style="width: 80%;"></textarea>
15
+ </div>
16
+ """
17
+
18
  iface = gr.Interface(
19
  fn=echo_text,
20
+ inputs=gr.Component(custom_interface, type="html"), # Use custom HTML interface
21
+ outputs=gr.Component("Output will be displayed here.", type="html"),
 
 
 
22
  live=True
23
  )
24