OldKingMeister commited on
Commit
36e2c9e
·
1 Parent(s): 6b4fee5

add inital app

Browse files
Files changed (1) hide show
  1. app.py +35 -0
app.py ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import uuid
2
+ import gradio as gr
3
+
4
+ TITLE = "UUID Generator"
5
+ MAX_UUIDS = 1000
6
+
7
+ def generate_uuids(count: int) -> str:
8
+ # Convert input to integer safely
9
+ try:
10
+ n = int(count)
11
+ except Exception:
12
+ n = 1
13
+ # Limit the number of UUIDs between 1 and 1000 to avoid excessive computation
14
+ n = max(1, min(n, MAX_UUIDS))
15
+ # Generate UUIDs and return them as a newline-separated string
16
+ return "\n".join(str(uuid.uuid4()) for _ in range(n))
17
+
18
+ with gr.Blocks(title=TITLE) as demo:
19
+ # App title and short instructions
20
+ gr.Markdown(f"# {TITLE}\nEnter how many UUIDs you want and click **Generate**.")
21
+
22
+ with gr.Row():
23
+ # Number input for how many UUIDs to generate
24
+ num = gr.Number(value=10, precision=0, minimum=1, maximum=MAX_UUIDS, label="How many UUIDs?")
25
+ # Button to trigger generation
26
+ btn = gr.Button("Generate", variant="primary")
27
+
28
+ # Output textbox showing UUIDs, one per line, with a copy button
29
+ out = gr.Textbox(label="UUIDs (one per line)", lines=16, show_copy_button=True)
30
+
31
+ # Connect button click to function
32
+ btn.click(generate_uuids, inputs=num, outputs=out)
33
+
34
+ if __name__ == "__main__":
35
+ demo.launch()