Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -211,13 +211,13 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 211 |
}
|
| 212 |
|
| 213 |
.gr-input:focus, .gr-textarea:focus {
|
| 214 |
-
border-color: #
|
| 215 |
outline: none !important;
|
| 216 |
-
box-shadow: 0 0 0 2px rgba(
|
| 217 |
}
|
| 218 |
|
| 219 |
.gr-button {
|
| 220 |
-
background-color: #
|
| 221 |
color: white !important;
|
| 222 |
border-radius: 6px !important;
|
| 223 |
padding: 8px 16px !important;
|
|
@@ -227,7 +227,7 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 227 |
}
|
| 228 |
|
| 229 |
.gr-button:hover {
|
| 230 |
-
background-color: #
|
| 231 |
}
|
| 232 |
|
| 233 |
.analysis-output {
|
|
@@ -236,12 +236,14 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 236 |
border-radius: 8px;
|
| 237 |
border: 1px solid #e0e5ff;
|
| 238 |
margin-top: 20px;
|
|
|
|
| 239 |
}
|
| 240 |
|
| 241 |
.analysis-output h1 {
|
| 242 |
font-size: 1.5em;
|
| 243 |
font-weight: bold;
|
| 244 |
margin-bottom: 1em;
|
|
|
|
| 245 |
}
|
| 246 |
|
| 247 |
.analysis-output h2 {
|
|
@@ -249,6 +251,9 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 249 |
font-weight: 600;
|
| 250 |
margin-top: 1.5em;
|
| 251 |
margin-bottom: 0.5em;
|
|
|
|
|
|
|
|
|
|
| 252 |
}
|
| 253 |
|
| 254 |
.analysis-output h3 {
|
|
@@ -256,20 +261,32 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 256 |
font-weight: 600;
|
| 257 |
margin-top: 1em;
|
| 258 |
margin-bottom: 0.5em;
|
|
|
|
| 259 |
}
|
| 260 |
|
| 261 |
.analysis-output ul {
|
| 262 |
margin-left: 1.5em;
|
| 263 |
margin-bottom: 1em;
|
|
|
|
| 264 |
}
|
| 265 |
|
| 266 |
.analysis-output li {
|
| 267 |
-
margin-bottom: 0.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 268 |
}
|
| 269 |
|
| 270 |
.analysis-output p {
|
| 271 |
margin-bottom: 1em;
|
| 272 |
line-height: 1.6;
|
|
|
|
| 273 |
}
|
| 274 |
|
| 275 |
.analysis-output code {
|
|
@@ -277,9 +294,56 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 277 |
padding: 0.2em 0.4em;
|
| 278 |
border-radius: 4px;
|
| 279 |
font-size: 0.9em;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 280 |
}
|
| 281 |
"""
|
| 282 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 283 |
async def run_analysis(api_key: str,
|
| 284 |
website_url: str,
|
| 285 |
product_category: str,
|
|
@@ -301,7 +365,7 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 301 |
product_category=product_category,
|
| 302 |
specific_product=specific_product if specific_product else None
|
| 303 |
)
|
| 304 |
-
return result
|
| 305 |
except Exception as e:
|
| 306 |
return f"Error during analysis: {str(e)}"
|
| 307 |
|
|
@@ -343,8 +407,7 @@ def create_gradio_interface() -> gr.Blocks:
|
|
| 343 |
|
| 344 |
analyze_button = gr.Button(
|
| 345 |
"Analyze Site",
|
| 346 |
-
size="lg"
|
| 347 |
-
variant="primary"
|
| 348 |
)
|
| 349 |
|
| 350 |
# Right column for output
|
|
|
|
| 211 |
}
|
| 212 |
|
| 213 |
.gr-input:focus, .gr-textarea:focus {
|
| 214 |
+
border-color: #3452DB !important;
|
| 215 |
outline: none !important;
|
| 216 |
+
box-shadow: 0 0 0 2px rgba(52, 82, 219, 0.2) !important;
|
| 217 |
}
|
| 218 |
|
| 219 |
.gr-button {
|
| 220 |
+
background-color: #3452DB !important;
|
| 221 |
color: white !important;
|
| 222 |
border-radius: 6px !important;
|
| 223 |
padding: 8px 16px !important;
|
|
|
|
| 227 |
}
|
| 228 |
|
| 229 |
.gr-button:hover {
|
| 230 |
+
background-color: #2a41af !important;
|
| 231 |
}
|
| 232 |
|
| 233 |
.analysis-output {
|
|
|
|
| 236 |
border-radius: 8px;
|
| 237 |
border: 1px solid #e0e5ff;
|
| 238 |
margin-top: 20px;
|
| 239 |
+
font-family: 'Open Sans', sans-serif;
|
| 240 |
}
|
| 241 |
|
| 242 |
.analysis-output h1 {
|
| 243 |
font-size: 1.5em;
|
| 244 |
font-weight: bold;
|
| 245 |
margin-bottom: 1em;
|
| 246 |
+
color: #1a1a1a;
|
| 247 |
}
|
| 248 |
|
| 249 |
.analysis-output h2 {
|
|
|
|
| 251 |
font-weight: 600;
|
| 252 |
margin-top: 1.5em;
|
| 253 |
margin-bottom: 0.5em;
|
| 254 |
+
color: #2a2a2a;
|
| 255 |
+
border-bottom: 2px solid #e0e5ff;
|
| 256 |
+
padding-bottom: 0.5em;
|
| 257 |
}
|
| 258 |
|
| 259 |
.analysis-output h3 {
|
|
|
|
| 261 |
font-weight: 600;
|
| 262 |
margin-top: 1em;
|
| 263 |
margin-bottom: 0.5em;
|
| 264 |
+
color: #3a3a3a;
|
| 265 |
}
|
| 266 |
|
| 267 |
.analysis-output ul {
|
| 268 |
margin-left: 1.5em;
|
| 269 |
margin-bottom: 1em;
|
| 270 |
+
list-style-type: none;
|
| 271 |
}
|
| 272 |
|
| 273 |
.analysis-output li {
|
| 274 |
+
margin-bottom: 0.8em;
|
| 275 |
+
position: relative;
|
| 276 |
+
line-height: 1.6;
|
| 277 |
+
}
|
| 278 |
+
|
| 279 |
+
.analysis-output li:before {
|
| 280 |
+
content: "β’";
|
| 281 |
+
position: absolute;
|
| 282 |
+
left: -1.2em;
|
| 283 |
+
color: #3452DB;
|
| 284 |
}
|
| 285 |
|
| 286 |
.analysis-output p {
|
| 287 |
margin-bottom: 1em;
|
| 288 |
line-height: 1.6;
|
| 289 |
+
color: #4a4a4a;
|
| 290 |
}
|
| 291 |
|
| 292 |
.analysis-output code {
|
|
|
|
| 294 |
padding: 0.2em 0.4em;
|
| 295 |
border-radius: 4px;
|
| 296 |
font-size: 0.9em;
|
| 297 |
+
color: #3452DB;
|
| 298 |
+
}
|
| 299 |
+
|
| 300 |
+
/* Star rating styles */
|
| 301 |
+
.star-rating {
|
| 302 |
+
color: #3452DB;
|
| 303 |
+
letter-spacing: 2px;
|
| 304 |
+
}
|
| 305 |
+
|
| 306 |
+
/* Section dividers */
|
| 307 |
+
.section-divider {
|
| 308 |
+
border-top: 1px solid #e0e5ff;
|
| 309 |
+
margin: 2em 0;
|
| 310 |
+
}
|
| 311 |
+
|
| 312 |
+
/* Score indicators */
|
| 313 |
+
.score-indicator {
|
| 314 |
+
background: #f8f9ff;
|
| 315 |
+
padding: 0.5em 1em;
|
| 316 |
+
border-radius: 4px;
|
| 317 |
+
border-left: 4px solid #3452DB;
|
| 318 |
+
margin: 1em 0;
|
| 319 |
+
}
|
| 320 |
+
|
| 321 |
+
/* Special formatting for emojis */
|
| 322 |
+
.emoji-icon {
|
| 323 |
+
font-size: 1.2em;
|
| 324 |
+
margin-right: 0.5em;
|
| 325 |
+
vertical-align: middle;
|
| 326 |
}
|
| 327 |
"""
|
| 328 |
|
| 329 |
+
def format_markdown_report(report_text: str) -> str:
|
| 330 |
+
"""Format the report text with proper Markdown and styling"""
|
| 331 |
+
# Add custom CSS classes and formatting
|
| 332 |
+
report_text = report_text.replace("============================", "")
|
| 333 |
+
report_text = report_text.replace("-----------------------------", "")
|
| 334 |
+
|
| 335 |
+
# Add styling to score sections
|
| 336 |
+
report_text = report_text.replace("[β
β
β
β
β]", "<span class='star-rating'>β
β
β
β
β</span>")
|
| 337 |
+
report_text = report_text.replace("π", "<span class='emoji-icon'>π</span>")
|
| 338 |
+
report_text = report_text.replace("π", "<span class='emoji-icon'>π</span>")
|
| 339 |
+
report_text = report_text.replace("π", "<span class='emoji-icon'>π</span>")
|
| 340 |
+
report_text = report_text.replace("π", "<span class='emoji-icon'>π</span>")
|
| 341 |
+
report_text = report_text.replace("π°", "<span class='emoji-icon'>π°</span>")
|
| 342 |
+
report_text = report_text.replace("π", "<span class='emoji-icon'>π</span>")
|
| 343 |
+
report_text = report_text.replace("π§", "<span class='emoji-icon'>π§</span>")
|
| 344 |
+
|
| 345 |
+
return report_text
|
| 346 |
+
|
| 347 |
async def run_analysis(api_key: str,
|
| 348 |
website_url: str,
|
| 349 |
product_category: str,
|
|
|
|
| 365 |
product_category=product_category,
|
| 366 |
specific_product=specific_product if specific_product else None
|
| 367 |
)
|
| 368 |
+
return format_markdown_report(result)
|
| 369 |
except Exception as e:
|
| 370 |
return f"Error during analysis: {str(e)}"
|
| 371 |
|
|
|
|
| 407 |
|
| 408 |
analyze_button = gr.Button(
|
| 409 |
"Analyze Site",
|
| 410 |
+
size="lg"
|
|
|
|
| 411 |
)
|
| 412 |
|
| 413 |
# Right column for output
|