codeboosterstech commited on
Commit
0297da2
·
verified ·
1 Parent(s): 56ea690

Add app.py via Space Creator

Browse files
Files changed (1) hide show
  1. app.py +82 -0
app.py ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ # Original code snippet
4
+ # def add(a, b):
5
+ # return a + b
6
+ #
7
+ # def subtract(a, b):
8
+ # return a - b
9
+ #
10
+ # def multiply(a, b):
11
+ # return a * b
12
+ #
13
+ # def divide(a, b):
14
+ # if b == 0:
15
+ # return "Error: Cannot divide by zero"
16
+ # return a / b
17
+ #
18
+ # def calculator():
19
+ # print("Simple Calculator")
20
+ # print("Operations: + - * /")
21
+ #
22
+ # while True:
23
+ # op = input("Enter operation (+, -, *, /) or 'q' to quit: ")
24
+ #
25
+ # if op.lower() == 'q':
26
+ # print("Exiting calculator.")
27
+ # break
28
+ #
29
+ # if op not in ['+', '-', '*', '/']:
30
+ # print("Invalid operation.")
31
+ # continue
32
+ #
33
+ # try:
34
+ # num1 = float(input("Enter first number: "))
35
+ # num2 = float(input("Enter second number: "))
36
+ # except ValueError:
37
+ # print("Invalid input. Please enter numbers.")
38
+ # continue
39
+ #
40
+ # if op == '+':
41
+ # result = add(num1, num2)
42
+ # elif op == '-':
43
+ # result = subtract(num1, num2)
44
+ # elif op == '*':
45
+ # result = multiply(num1, nu
46
+
47
+ # Gradio interface
48
+ def process_input(input_text):
49
+ try:
50
+ # Process the input
51
+ return f"Processed: {input_text}"
52
+ except Exception as e:
53
+ return f"Error: {str(e)}"
54
+
55
+ # Create the Gradio app
56
+ with gr.Blocks(title="Generated Application", theme=gr.themes.Soft()) as demo:
57
+ gr.Markdown("# Generated Application")
58
+
59
+ with gr.Row():
60
+ with gr.Column():
61
+ input_box = gr.Textbox(
62
+ label="Input Text",
63
+ placeholder="Enter text to process...",
64
+ lines=3
65
+ )
66
+ submit_btn = gr.Button("Process", variant="primary")
67
+
68
+ with gr.Row():
69
+ output_box = gr.Textbox(
70
+ label="Output",
71
+ interactive=False,
72
+ lines=5
73
+ )
74
+
75
+ submit_btn.click(
76
+ fn=process_input,
77
+ inputs=[input_box],
78
+ outputs=[output_box]
79
+ )
80
+
81
+ if __name__ == "__main__":
82
+ demo.launch(share=False)