seanangbee commited on
Commit
c100a4b
·
verified ·
1 Parent(s): 178ff29

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +99 -0
app.py ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+
3
+ def reverse_text(text):
4
+ if not text:
5
+ return ""
6
+ return text[::-1]
7
+
8
+ # Custom CSS for professional styling with pink submit button
9
+ custom_css = """
10
+ #component-0 {
11
+ max-width: 800px;
12
+ margin: 0 auto;
13
+ padding: 20px;
14
+ }
15
+
16
+ .gradio-container {
17
+ font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif !important;
18
+ }
19
+
20
+ h1 {
21
+ text-align: center;
22
+ color: #1f2937;
23
+ font-weight: 600;
24
+ margin-bottom: 10px;
25
+ }
26
+
27
+ .contain {
28
+ background: white;
29
+ border-radius: 12px;
30
+ box-shadow: 0 1px 3px rgba(0,0,0,0.1);
31
+ }
32
+
33
+ button.primary {
34
+ background: linear-gradient(135deg, #ec4899 0%, #db2777 100%) !important;
35
+ border: none !important;
36
+ color: white !important;
37
+ font-weight: 500 !important;
38
+ padding: 10px 24px !important;
39
+ border-radius: 8px !important;
40
+ transition: all 0.3s ease !important;
41
+ }
42
+
43
+ button.primary:hover {
44
+ transform: translateY(-1px) !important;
45
+ box-shadow: 0 4px 12px rgba(236, 72, 153, 0.4) !important;
46
+ }
47
+
48
+ .output-class {
49
+ background: #f9fafb;
50
+ border-radius: 8px;
51
+ padding: 16px;
52
+ }
53
+ """
54
+
55
+ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as app:
56
+ gr.Markdown(
57
+ """
58
+ # Text Reverser
59
+ ### Transform your text with a simple reverse operation
60
+ Enter any text below and watch it get reversed instantly.
61
+ """
62
+ )
63
+
64
+ with gr.Row():
65
+ with gr.Column():
66
+ input_text = gr.Textbox(
67
+ label="Input Text",
68
+ placeholder="Type or paste your text here...",
69
+ lines=5,
70
+ max_lines=10
71
+ )
72
+
73
+ submit_btn = gr.Button("Reverse Text", variant="primary", size="lg")
74
+
75
+ with gr.Row():
76
+ with gr.Column():
77
+ output_text = gr.Textbox(
78
+ label="Reversed Text",
79
+ lines=5,
80
+ max_lines=10,
81
+ interactive=False,
82
+ elem_classes=["output-class"]
83
+ )
84
+
85
+ # Connect the button to the function
86
+ submit_btn.click(fn=reverse_text, inputs=input_text, outputs=output_text)
87
+
88
+ # Also trigger on Enter key in the input
89
+ input_text.submit(fn=reverse_text, inputs=input_text, outputs=output_text)
90
+
91
+ gr.Markdown(
92
+ """
93
+ ---
94
+ *Tip: Press Enter in the input field or click the button to reverse your text*
95
+ """
96
+ )
97
+
98
+ if __name__ == "__main__":
99
+ app.launch()