tapas0A commited on
Commit
5896565
·
1 Parent(s): 26c64bc

Upload with huggingface_hub

Browse files
Files changed (4) hide show
  1. Dockerfile +11 -0
  2. app.py +16 -0
  3. requirements.txt +1 -0
  4. test.py +6 -0
Dockerfile ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM python:3.8-slim-buster
2
+
3
+ WORKDIR /app
4
+
5
+ COPY requirements.txt .
6
+
7
+ RUN pip3 install -r requirements.txt
8
+
9
+ COPY . .
10
+
11
+ CMD ["python3", "app.py"]
app.py ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import random
3
+
4
+ def generate_text(length):
5
+ text = ""
6
+ for i in range(length):
7
+ text += chr(random.randint(97, 122))
8
+ return text
9
+
10
+ input_text = gr.inputs.Slider(minimum=1, maximum=100, default=50, label="Length of Text")
11
+ output_text = gr.outputs.Textbox(label="Generated Text")
12
+
13
+ title = "Random Text Generator"
14
+ description = "Generate random text of a specified length."
15
+
16
+ gr.Interface(fn=generate_text, inputs=input_text, outputs=output_text, title=title, description=description).launch()
requirements.txt ADDED
@@ -0,0 +1 @@
 
 
1
+ gradio
test.py ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ import app
2
+
3
+ def test_generate_text():
4
+ assert len(app.generate_text(10)) == 10
5
+ assert len(app.generate_text(100)) == 100
6
+ assert len(app.generate_text(1000)) == 1000