ChienChung commited on
Commit
b1e35d1
·
verified ·
1 Parent(s): b7a6217

Update web_ui.py

Browse files
Files changed (1) hide show
  1. web_ui.py +13 -86
web_ui.py CHANGED
@@ -104,93 +104,21 @@ def search_handler(keyword):
104
  except Exception as e:
105
  return f"Search failed: {str(e)}"
106
 
107
- # Custom CSS for beautiful styling
108
- custom_css = """
109
- #main-container {
110
- max-width: 1200px;
111
- margin: 0 auto;
112
- padding: 20px;
113
- }
114
 
115
- #title-header {
116
- text-align: center;
117
- background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
118
- color: white;
119
- padding: 30px;
120
- border-radius: 15px;
121
- margin-bottom: 30px;
122
- box-shadow: 0 8px 32px rgba(0,0,0,0.1);
123
- }
124
-
125
- #main-input-card {
126
- background: white;
127
- padding: 25px;
128
- border-radius: 12px;
129
- box-shadow: 0 4px 20px rgba(0,0,0,0.08);
130
- margin-bottom: 20px;
131
- border: 1px solid #e1e8ed;
132
- }
133
-
134
- #results-container {
135
- background: white;
136
- padding: 20px;
137
- border-radius: 12px;
138
- box-shadow: 0 4px 20px rgba(0,0,0,0.08);
139
- margin: 20px 0;
140
- border: 1px solid #e1e8ed;
141
- }
142
-
143
- #analyse-btn {
144
- background: linear-gradient(45deg, #667eea, #764ba2);
145
- border: none;
146
- color: white;
147
- font-weight: 500;
148
- height: 52px;
149
- border-radius: 8px;
150
- transition: all 0.3s ease;
151
- margin-top: 20px;
152
- }
153
-
154
- #analyse-btn:hover {
155
- transform: translateY(-2px);
156
- box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
157
- }
158
-
159
- .example-btn {
160
- height: 52px !important;
161
- margin-top: 16px !important;
162
- }
163
-
164
- .quick-examples {
165
- background: #f8f9fa;
166
- border-radius: 10px;
167
- padding: 15px;
168
- margin: 15px 0;
169
- border: 1px solid #e9ecef;
170
- }
171
-
172
- .search-section {
173
- background: #fff;
174
- border-radius: 10px;
175
- padding: 20px;
176
- margin: 15px 0;
177
- border: 1px solid #e1e8ed;
178
- box-shadow: 0 2px 10px rgba(0,0,0,0.05);
179
- }
180
- """
181
-
182
- # Main interface with beautiful styling
183
- with gr.Blocks(css=custom_css, title="CVE Analysis Agent", theme=gr.themes.Soft()) as interface:
184
 
185
- with gr.Column(elem_id="main-container"):
186
- # Beautiful header - ONLY keep main title
187
- with gr.Row(elem_id="title-header"):
188
  gr.Markdown("""
189
  # CVE Analysis Agent
190
  """)
191
 
192
  # Main input card
193
- with gr.Column(elem_id="main-input-card"):
194
  gr.Markdown("### Enter CVE ID for Analysis")
195
 
196
  with gr.Row():
@@ -204,12 +132,11 @@ with gr.Blocks(css=custom_css, title="CVE Analysis Agent", theme=gr.themes.Soft(
204
  analyse_btn = gr.Button(
205
  "Analyse",
206
  variant="primary",
207
- scale=1,
208
- elem_id="analyse-btn"
209
  )
210
 
211
  # Quick examples section
212
- with gr.Row(elem_classes="quick-examples"):
213
  gr.Markdown("**Quick Examples:**")
214
  example_dropdown = gr.Dropdown(
215
  choices=[f"{cve} - {desc}" for cve, desc in EXAMPLE_CVES],
@@ -217,10 +144,10 @@ with gr.Blocks(css=custom_css, title="CVE Analysis Agent", theme=gr.themes.Soft(
217
  value=None,
218
  scale=3
219
  )
220
- example_btn = gr.Button("Try Example", variant="secondary", scale=1, elem_classes="example-btn")
221
 
222
  # Results container
223
- with gr.Column(elem_id="results-container"):
224
  gr.Markdown("### Analysis Results")
225
 
226
  # CVE Information on top
@@ -237,7 +164,7 @@ with gr.Blocks(css=custom_css, title="CVE Analysis Agent", theme=gr.themes.Soft(
237
 
238
  # Search section
239
  with gr.Accordion("Search Previously Analysed CVEs", open=False):
240
- with gr.Column(elem_classes="search-section"):
241
  gr.Markdown("**Search through your analysed vulnerabilities**")
242
  with gr.Row():
243
  search_input = gr.Textbox(
 
104
  except Exception as e:
105
  return f"Search failed: {str(e)}"
106
 
107
+ # 移除自定義CSS,讓Gradio主題完全控制樣式
108
+ # 這樣深色模式和淺色模式都會完美適配
 
 
 
 
 
109
 
110
+ # Main interface with Gradio default styling (支援深色/淺色模式)
111
+ with gr.Blocks(title="CVE Analysis Agent", theme=gr.themes.Default(primary_hue="violet")) as interface:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
+ with gr.Column():
114
+ # Beautiful header
115
+ with gr.Row():
116
  gr.Markdown("""
117
  # CVE Analysis Agent
118
  """)
119
 
120
  # Main input card
121
+ with gr.Column():
122
  gr.Markdown("### Enter CVE ID for Analysis")
123
 
124
  with gr.Row():
 
132
  analyse_btn = gr.Button(
133
  "Analyse",
134
  variant="primary",
135
+ scale=1
 
136
  )
137
 
138
  # Quick examples section
139
+ with gr.Row():
140
  gr.Markdown("**Quick Examples:**")
141
  example_dropdown = gr.Dropdown(
142
  choices=[f"{cve} - {desc}" for cve, desc in EXAMPLE_CVES],
 
144
  value=None,
145
  scale=3
146
  )
147
+ example_btn = gr.Button("Try Example", variant="secondary", scale=1)
148
 
149
  # Results container
150
+ with gr.Column():
151
  gr.Markdown("### Analysis Results")
152
 
153
  # CVE Information on top
 
164
 
165
  # Search section
166
  with gr.Accordion("Search Previously Analysed CVEs", open=False):
167
+ with gr.Column():
168
  gr.Markdown("**Search through your analysed vulnerabilities**")
169
  with gr.Row():
170
  search_input = gr.Textbox(