uumerrr684 commited on
Commit
0891f1f
·
verified ·
1 Parent(s): cab2c2f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +47 -75
app.py CHANGED
@@ -2,7 +2,7 @@ import os
2
  import requests
3
  import gradio as gr
4
 
5
- # Token setup (keep your working version)
6
  TOKEN = os.getenv("HF_API_TOKEN", "").strip()
7
 
8
  def summarize(text):
@@ -24,83 +24,85 @@ def summarize(text):
24
  except Exception as e:
25
  return f"🚨 Error: {str(e)}", ""
26
 
27
- # ======= FIXED & ENHANCED UI ======= #
28
  custom_css = """
29
  .gradio-container {
30
- max-width: 800px !important;
31
- margin: auto !important;
 
 
 
 
32
  }
33
- #input-box {
34
- font-family: 'Helvetica', sans-serif;
35
- border-radius: 12px !important;
36
  padding: 15px !important;
37
- background: white !important;
 
 
38
  }
39
- #output-box {
40
- font-family: 'Helvetica', sans-serif;
41
- border-radius: 12px !important;
42
- padding: 15px !important;
43
- background: #f8f9fa !important;
44
  }
45
- #submit-btn {
46
- background: linear-gradient(45deg, #FF6B6B, #4ECDC4) !important;
47
- border: none !important;
48
  color: white !important;
49
- font-weight: bold !important;
50
  border-radius: 8px !important;
51
  padding: 12px 24px !important;
52
- transition: all 0.3s !important;
 
53
  }
54
- #submit-btn:hover {
55
- transform: scale(1.02) !important;
56
- box-shadow: 0 4px 12px rgba(0,0,0,0.15) !important;
57
  }
58
  .header {
59
  text-align: center;
60
- font-weight: 800 !important;
61
  font-size: 2em !important;
62
- background: linear-gradient(45deg, #4F6BFF, #8E54E9);
63
- -webkit-background-clip: text;
64
- -webkit-text-fill-color: transparent;
65
  margin-bottom: 10px !important;
66
  }
67
  .subheader {
68
  text-align: center;
69
- color: #666 !important;
70
  margin-bottom: 20px !important;
71
  }
72
  .status {
73
- font-size: 0.9em;
74
- padding: 8px;
75
- border-radius: 6px;
 
76
  text-align: center;
77
- background: #f0f0f0;
78
  }
79
- .dark .status {
80
- background: #333 !important;
81
  color: white !important;
 
 
 
 
82
  }
83
  """
84
 
85
- with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as app:
86
  gr.Markdown("""
87
  <div class='header'>✨ SUMMIFY PRO ✨</div>
88
- <div class='subheader'>Transform long texts into concise summaries</div>
89
  """)
90
 
91
  with gr.Row():
92
  input_txt = gr.Textbox(
93
  label="Your Text",
94
- placeholder="Paste any article, essay, or document here...",
95
  lines=7,
96
- elem_id="input-box",
97
- interactive=True # THIS WAS THE FIX - REMOVED THE DISABLED STATE
98
  )
99
  output_txt = gr.Textbox(
100
  label="Summary",
101
  lines=7,
102
  elem_id="output-box",
103
- interactive=False # Output should remain non-editable
104
  )
105
 
106
  status = gr.Textbox(
@@ -110,46 +112,16 @@ with gr.Blocks(css=custom_css, theme=gr.themes.Soft()) as app:
110
  )
111
 
112
  with gr.Row():
113
- submit_btn = gr.Button(
114
  "Summarize",
115
- variant="primary",
116
  elem_id="submit-btn"
117
  )
118
- clear_btn = gr.ClearButton(
119
- components=[input_txt, output_txt, status],
120
- value="🗑️ Clear All"
 
 
 
121
  )
122
-
123
- submit_btn.click(
124
- fn=summarize,
125
- inputs=input_txt,
126
- outputs=[output_txt, status]
127
- )
128
-
129
- # Enhanced dark mode toggle
130
- gr.HTML("""
131
- <script>
132
- function toggleDark() {
133
- document.body.classList.toggle('dark');
134
- localStorage.setItem('darkMode', document.body.classList.contains('dark'));
135
- }
136
- if (localStorage.getItem('darkMode') === 'true') {
137
- document.body.classList.add('dark');
138
- }
139
- </script>
140
- <button onclick="toggleDark()" style="
141
- position: fixed;
142
- bottom: 20px;
143
- right: 20px;
144
- padding: 10px;
145
- border-radius: 50%;
146
- background: #4F6BFF;
147
- color: white;
148
- border: none;
149
- cursor: pointer;
150
- box-shadow: 0 2px 10px rgba(0,0,0,0.2);
151
- z-index: 999;
152
- ">🌓</button>
153
- """)
154
 
155
  app.launch(server_name="0.0.0.0")
 
2
  import requests
3
  import gradio as gr
4
 
5
+ # Token setup
6
  TOKEN = os.getenv("HF_API_TOKEN", "").strip()
7
 
8
  def summarize(text):
 
24
  except Exception as e:
25
  return f"🚨 Error: {str(e)}", ""
26
 
27
+ # ======= PURPLE THEME ======= #
28
  custom_css = """
29
  .gradio-container {
30
+ background: #6A0DAD !important;
31
+ color: white !important;
32
+ max-width: 800px;
33
+ margin: auto;
34
+ border-radius: 15px;
35
+ padding: 20px;
36
  }
37
+ #input-box, #output-box {
38
+ font-family: 'Arial', sans-serif;
39
+ border-radius: 10px !important;
40
  padding: 15px !important;
41
+ background: #8A2BE2 !important;
42
+ color: white !important;
43
+ border: 2px solid #9370DB !important;
44
  }
45
+ #input-box::placeholder {
46
+ color: #D8BFD8 !important;
 
 
 
47
  }
48
+ #submit-btn, .clear-btn {
49
+ background: #9370DB !important;
 
50
  color: white !important;
51
+ border: none !important;
52
  border-radius: 8px !important;
53
  padding: 12px 24px !important;
54
+ font-weight: bold !important;
55
+ margin: 5px !important;
56
  }
57
+ #submit-btn:hover, .clear-btn:hover {
58
+ background: #8A2BE2 !important;
59
+ transform: scale(1.02);
60
  }
61
  .header {
62
  text-align: center;
 
63
  font-size: 2em !important;
64
+ color: white !important;
 
 
65
  margin-bottom: 10px !important;
66
  }
67
  .subheader {
68
  text-align: center;
69
+ color: #D8BFD8 !important;
70
  margin-bottom: 20px !important;
71
  }
72
  .status {
73
+ background: #8A2BE2 !important;
74
+ color: white !important;
75
+ border-radius: 8px;
76
+ padding: 10px;
77
  text-align: center;
 
78
  }
79
+ label {
 
80
  color: white !important;
81
+ font-weight: bold !important;
82
+ }
83
+ footer {
84
+ visibility: hidden;
85
  }
86
  """
87
 
88
+ with gr.Blocks(css=custom_css) as app:
89
  gr.Markdown("""
90
  <div class='header'>✨ SUMMIFY PRO ✨</div>
91
+ <div class='subheader'>Transform texts into concise summaries</div>
92
  """)
93
 
94
  with gr.Row():
95
  input_txt = gr.Textbox(
96
  label="Your Text",
97
+ placeholder="Type or paste your content here...",
98
  lines=7,
99
+ elem_id="input-box"
 
100
  )
101
  output_txt = gr.Textbox(
102
  label="Summary",
103
  lines=7,
104
  elem_id="output-box",
105
+ interactive=False
106
  )
107
 
108
  status = gr.Textbox(
 
112
  )
113
 
114
  with gr.Row():
115
+ gr.Button(
116
  "Summarize",
 
117
  elem_id="submit-btn"
118
  )
119
+ gr.Button(
120
+ "Clear",
121
+ elem_classes="clear-btn"
122
+ ).click(
123
+ lambda: ["", "", ""],
124
+ outputs=[input_txt, output_txt, status]
125
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
126
 
127
  app.launch(server_name="0.0.0.0")