ZeroTech commited on
Commit
764949d
1 Parent(s): 5bfa84c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -18
app.py CHANGED
@@ -1,24 +1,13 @@
1
  import gradio as gr
2
  import random
3
 
4
- def generate_random_words(num_words):
5
- words = []
6
- for i in range(num_words):
7
- word_length = random.randint(5, 10)
8
- word = ''.join(random.choice('abcdefghijklmnopqrstuvwxyz') for _ in range(word_length))
9
- words.append(word)
10
- return ' '.join(words)
11
 
12
- interface = gr.Interface(
13
- fn=generate_random_words,
14
- inputs=gr.inputs.Number(default=5, label='Number of words'),
15
- outputs='text',
16
- title='Random Word Generator',
17
- description='Generate random words of length 5-10 characters.',
18
- layout='vertical',
19
- allow_flagging=False,
20
- theme='default',
21
- verbose=False,
22
- )
23
 
 
24
  interface.launch()
 
1
  import gradio as gr
2
  import random
3
 
4
+ def generate_word(input_words):
5
+ words = input_words.split(",")
6
+ random_word = random.choice(words)
7
+ return random_word
 
 
 
8
 
9
+ input_box = gr.inputs.Textbox(label="Enter words separated by commas")
10
+ output_text = gr.outputs.Textbox(label="Random word")
 
 
 
 
 
 
 
 
 
11
 
12
+ interface = gr.Interface(fn=generate_word, inputs=input_box, outputs=output_text, title="Random Word Generator")
13
  interface.launch()