Spaces:
Sleeping
Sleeping
Download ui.py from ghstedpixel/app.py: direct link, hf CLI and curl.
- Browser
- Download file 15.8 kB
-
https://huggingface.co/spaces/ghstedpixel/app.py/resolve/4fa2fd90c00a78d4e4e68ccd489221ffc5d7362b/ui.py
- Command line
-
hf download hf://spaces/ghstedpixel/app.py@4fa2fd90c00a78d4e4e68ccd489221ffc5d7362b/ui.py
-
curl -L -o ui.py https://huggingface.co/spaces/ghstedpixel/app.py/resolve/4fa2fd90c00a78d4e4e68ccd489221ffc5d7362b/ui.py
15.8 kB
| from database import redis_client | |
| def generate_ui(results_html: str = "", error_msg: str = "", prev_name: str = "", prev_size: str = "", prev_mode: str = "balanced", prev_gender: str = "unisex") -> str: | |
| error_html = f'<div class="error">{error_msg}</div>' if error_msg else '' | |
| status_text = "Real-Time Pricing Intelligence & Value Verification" if redis_client else "Security Protection Active | Core Memory Tracking" | |
| status_color = "var(--accent-green)" if redis_client else "#f59e0b" | |
| return f""" | |
| <!DOCTYPE html> | |
| <html> | |
| <head> | |
| <title>Tarz Price Scout</title> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no"> | |
| <link rel="preconnect" href="https://fonts.googleapis.com"> | |
| <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin> | |
| <link href="https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap" rel="stylesheet"> | |
| <style> | |
| :root {{ | |
| --bg-main: #0a0c14; --card-bg: #131622; --input-bg: #1b1f32; --border-color: rgba(255, 255, 255, 0.08); | |
| --text-main: #f3f4f6; --text-muted: #9ca3af; --accent-blue: #3b82f6; --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #1d4ed8 100%); | |
| --accent-green: #10b981; --glow-green: rgba(16, 185, 129, 0.2); --accent-gold: #f59e0b; | |
| }} | |
| * {{ box-sizing: border-box; }} | |
| body {{ | |
| font-family: 'Inter', -apple-system, sans-serif; | |
| padding: 40px 20px; | |
| background: radial-gradient(circle at 50% 0%, #16192b 0%, #08090f 100%); | |
| background-attachment: fixed; | |
| color: var(--text-main); | |
| max-width: 850px; | |
| margin: auto; | |
| line-height: 1.5; | |
| -webkit-text-size-adjust: 100%; | |
| }} | |
| h2 {{ font-size: 28px; font-weight: 700; letter-spacing: -0.025em; margin-bottom: 4px; color: #ffffff; display: flex; align-items: center; gap: 12px; }} | |
| h3 {{ font-size: 18px; font-weight: 600; color: #ffffff; margin-top: 0; margin-bottom: 20px; display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }} | |
| .status-line {{ display: inline-flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; color: var(--text-muted); margin-bottom: 30px; background: rgba(255,255,255,0.02); padding: 6px 14px; border-radius: 20px; border: 1px solid var(--border-color); }} | |
| .status-pill {{ width: 8px; height: 8px; background: {status_color}; border-radius: 50%; box-shadow: 0 0 12px {status_color}; }} | |
| .card {{ background: var(--card-bg); padding: 24px; border-radius: 16px; border: 1px solid var(--border-color); margin-bottom: 24px; box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4); }} | |
| .input-flex {{ display: flex; gap: 16px; margin-bottom: 20px; align-items: flex-end; }} | |
| .input-group {{ display: flex; flex-direction: column; flex-grow: 1; min-width: 0; }} | |
| .input-group.size-group {{ flex-grow: 0; width: 140px; }} | |
| .input-group.gender-group {{ flex-grow: 0; width: 105px; }} | |
| .input-group.mode-group {{ flex-grow: 0; width: 175px; }} | |
| label {{ min-height: 32px; display: flex; align-items: flex-end; margin-bottom: 8px; font-weight: 500; color: var(--text-muted); font-size: 13px; line-height: 1.2; }} | |
| input[type="text"], select {{ background: var(--input-bg); border: 1px solid var(--border-color); color: white; padding: 14px 16px; border-radius: 10px; font-size: 15px; transition: all 0.3s ease; font-family: inherit; width: 100%; height: 50px; }} | |
| .input-group.gender-group select {{ padding: 14px 22px 14px 12px; font-size: 14px; background-position: right 6px center; }} | |
| select {{ cursor: pointer; -webkit-appearance: none; appearance: none; background-image: url('data:image/svg+xml;utf8,<svg fill="white" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/></svg>'); background-repeat: no-repeat; background-position: right 12px center; padding-right: 32px; }} | |
| input[type="text"]:focus, select:focus {{ border-color: var(--accent-blue); outline: none; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15); }} | |
| button {{ background: var(--accent-gradient); color: white; border: none; padding: 14px 24px; border-radius: 10px; cursor: pointer; font-weight: 600; font-size: 15px; transition: all 0.2s ease; display: inline-flex; align-items: center; justify-content: center; gap: 8px; width: 100%; box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2); font-family: inherit; }} | |
| button:hover {{ transform: translateY(-1px); box-shadow: 0 6px 16px rgba(59, 130, 246, 0.3); }} | |
| ul {{ list-style-type: none; padding: 0; margin: 0; }} | |
| li {{ background: rgba(255, 255, 255, 0.02); padding: 14px 18px; border-radius: 12px; margin-bottom: 12px; border: 1px solid var(--border-color); display: flex; flex-direction: column; gap: 12px; transition: all 0.2s ease; }} | |
| li:hover {{ border-color: rgba(255, 255, 255, 0.15); background: rgba(255, 255, 255, 0.04); }} | |
| .deal-item-header {{ display: flex; align-items: center; justify-content: space-between; width: 100%; gap: 16px; }} | |
| .deal-item {{ border-left: 4px solid var(--accent-green); background: #161c2a; overflow: hidden; }} | |
| .product-img {{ width: 52px; height: 52px; min-width: 52px; border-radius: 6px; object-fit: contain; aspect-ratio: 1 / 1; background: #0f111a; border: 1px solid var(--border-color); padding: 2px; }} | |
| .deal-info {{ flex-grow: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }} | |
| .item-title {{ font-weight: 600; color: #ffffff; font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }} | |
| .meta-container {{ display: flex; align-items: center; gap: 8px; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; margin-top: 2px; }} | |
| .domain-badge {{ background: rgba(255, 255, 255, 0.05); color: #e5e7eb; font-size: 11px; font-weight: 500; padding: 2px 6px; border-radius: 4px; text-transform: lowercase; border: 1px solid var(--border-color); white-space: nowrap; }} | |
| .size-badge {{ background: rgba(59, 130, 246, 0.1); color: #60a5fa; font-size: 11px; font-weight: 500; padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(59, 130, 246, 0.15); white-space: nowrap; }} | |
| .rating-badge {{ background: rgba(245, 158, 11, 0.1); color: #fbbf24; font-size: 11px; font-weight: 600; padding: 2px 6px; border-radius: 4px; border: 1px solid rgba(245, 158, 11, 0.2); white-space: nowrap; display: inline-flex; align-items: center; gap: 4px; }} | |
| .value-badge {{ display: inline-flex; align-items: center; gap: 4px; font-size: 11px; font-weight: 600; padding: 2px 7px; border-radius: 4px; text-transform: uppercase; letter-spacing: 0.02em; white-space: nowrap; }} | |
| .value-badge.best-value {{ background: rgba(16, 185, 129, 0.15); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.3); box-shadow: 0 0 8px rgba(16, 185, 129, 0.1); }} | |
| .value-badge.verified-retailer {{ background: rgba(245, 158, 11, 0.15); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.3); }} | |
| .small-link {{ color: var(--text-muted); text-decoration: none; font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 170px; }} | |
| .small-link:hover {{ text-decoration: underline; color: #60a5fa; }} | |
| /* HOVER CAPABLE CLICKABLE RETAIL TAG WRAPPER SETS */ | |
| .price-tag {{ background: var(--accent-green); color: white; border-radius: 8px; font-weight: 700; font-size: 16px; text-align: center; white-space: nowrap; min-width: 80px; box-shadow: 0 4px 10px rgba(16, 185, 129, 0.15); padding: 0; transition: transform 0.2s ease; }} | |
| .price-tag:hover {{ transform: scale(1.03); background: #059669; }} | |
| .price-tag a {{ display: block; color: white; text-decoration: none; padding: 8px 14px; width: 100%; height: 100%; }} | |
| /* DYNAMIC TREND INDICATORS COLOR MATRICES */ | |
| .trend-indicator {{ font-size: 11px; font-weight: 700; font-family: monospace; margin-top: 4px; text-align: right; white-space: nowrap; }} | |
| .trend-indicator.down {{ color: #ef4444; }} /* Red for Price Decreases (-) */ | |
| .trend-indicator.up {{ color: #10b981; }} /* Green for Price Increases (+) */ | |
| .error {{ color: #ef4444; background: rgba(239, 68, 68, 0.08); padding: 14px; border-radius: 10px; margin-bottom: 20px; border: 1px solid rgba(239, 68, 68, 0.2); font-size: 14px; font-weight: 500; display: flex; align-items: center; gap: 8px; }} | |
| .inline-coupon {{ background: rgba(245, 158, 11, 0.05); border: 1px dashed rgba(245, 158, 11, 0.3); padding: 8px 12px; border-radius: 8px; display: flex; align-items: center; justify-content: space-between; font-size: 12px; width: 100%; margin-top: 4px; }} | |
| details summary::-webkit-details-marker {{ display: none; }} | |
| details summary {{ list-style: none; display: flex; align-items: center; justify-content: center; gap: 8px; background: rgba(255,255,255,0.03); border: 1px solid var(--border-color); padding: 14px; border-radius: 12px; font-size: 14px; font-weight: 600; color: #ffffff; cursor: pointer; transition: all 0.2s ease; margin-top: 15px; }} | |
| details summary:hover {{ background: rgba(255,255,255,0.06); border-color: rgba(255,255,255,0.15); }} | |
| .loader-box {{ display: none; margin-top: 20px; }} | |
| .skeleton {{ background: linear-gradient(90deg, #1b1f32 25%, #252b47 50%, #1b1f32 75%); background-size: 200% 100%; animation: loading-shimmer 1.4s infinite linear; border-radius: 8px; }} | |
| @keyframes loading-shimmer {{ 0% {{ background-position: 200% 0; }} 100% {{ background-position: -200% 0; }} }} | |
| svg.icon {{ width: 16px; height: 16px; fill: currentColor; flex-shrink: 0; }} | |
| @media (max-width: 700px) {{ | |
| body {{ padding: 20px 12px; }} | |
| h2 {{ font-size: 22px; }} | |
| .card {{ padding: 16px; border-radius: 12px; margin-bottom: 16px; }} | |
| .input-flex {{ flex-direction: column; gap: 12px; margin-bottom: 16px; align-items: stretch; }} | |
| .input-group.size-group, .input-group.gender-group, .input-group.mode-group {{ width: 100%; }} | |
| label {{ min-height: auto; }} | |
| .deal-item-header {{ flex-direction: column; align-items: flex-start; gap: 12px; }} | |
| .product-img {{ width: 48px; height: 48px; min-width: 48px; }} | |
| .deal-info {{ width: 100%; }} | |
| .item-title {{ white-space: normal; font-size: 14px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }} | |
| .small-link {{ max-width: 100%; display: block; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }} | |
| .price-tag {{ width: 100%; text-align: center; }} | |
| button {{ padding: 12px 16px; font-size: 14px; }} | |
| }} | |
| </style> | |
| <script> | |
| function triggerLoadingState() {{ | |
| document.getElementById("submit-btn").style.display = "none"; | |
| document.getElementById("loader-zone").style.display = "block"; | |
| }} | |
| </script> | |
| </head> | |
| <body> | |
| <h2> | |
| <svg class="icon" style="width:28px; height:28px; color:var(--accent-blue);" viewBox="0 0 24 24"><path d="M12 2L2 22h20L12 2zm0 3.99L19.53 19H4.47L12 5.99zM13 16h-2v2h2v-2zm0-6h-2v4h2v-4z"/></svg> | |
| Tarz Price Scout | |
| </h2> | |
| <div class="status-line"> | |
| <div class="status-pill"></div> | |
| <span>{status_text}</span> | |
| </div> | |
| {error_html} | |
| <div class="card"> | |
| <h3> | |
| <svg class="icon" style="color:var(--accent-blue);" viewBox="0 0 24 24"><path d="M15.5 14h-.79l-.28-.27C15.41 12.59 16 11.11 16 9.5 16 5.91 13.09 3 9.5 3S3 5.91 3 9.5 5.91 16 9.5 16c1.61 0 3.09-.59 4.23-1.57l.27.28v.79l5 4.99L20.49 19l-4.99-5zm-6 0C7.01 14 5 11.99 5 9.5S7.01 5 9.5 5 14 7.01 14 9.5 11.99 14 9.5 14z"/></svg> | |
| Run On-Demand Scan | |
| </h3> | |
| <p style="font-size: 12px; color: var(--text-muted); margin-top: -10px; margin-bottom: 15px;">💡 Append an asterisk to force an engine refresh (e.g. <i>nike shorts *</i>)</p> | |
| <form action="/search" method="post" onsubmit="triggerLoadingState()"> | |
| <div class="input-flex"> | |
| <div class="input-group"> | |
| <label>Enter Product Details OR Paste Product Link</label> | |
| <input type="text" name="product_name" value="{prev_name}" placeholder="e.g., Creed Green Irish Tweed OR https://www.store.com/item" autocomplete="off" required> | |
| </div> | |
| <div class="input-group size-group"> | |
| <label>Size / Variant</label> | |
| <input type="text" name="product_size" value="{prev_size}" placeholder="e.g., 3.4 oz, XL, 10.5" autocomplete="off"> | |
| </div> | |
| <div class="input-group gender-group"> | |
| <label>Gender</label> | |
| <select name="product_gender"> | |
| <option value="unisex" {"selected" if prev_gender == "unisex" else ""}>All</option> | |
| <option value="mens" {"selected" if prev_gender == "mens" else ""}>Men's</option> | |
| <option value="womens" {"selected" if prev_gender == "womens" else ""}>Women's</option> | |
| <option value="kids" {"selected" if prev_gender == "kids" else ""}>Kids'</option> | |
| </select> | |
| </div> | |
| <div class="input-group mode-group"> | |
| <label>Search Strategy</label> | |
| <select name="search_mode"> | |
| <option value="broad" {"selected" if prev_mode == "broad" else ""}>Broad Exploration</option> | |
| <option value="balanced" {"selected" if prev_mode == "balanced" else ""}>Standard Balanced</option> | |
| <option value="exact" {"selected" if prev_mode == "exact" else ""}>Precision Match</option> | |
| </select> | |
| </div> | |
| </div> | |
| <button type="submit" id="submit-btn"> | |
| <svg class="icon" viewBox="0 0 24 24"><path d="M3 13h2v-2H3v2zm0 4h2v-2H3v2zm0-8h2V7H3v2zm4 4h14v-2H7v2zm0 4h14v-2H7v2zM7 7v2h14V7H7z"/></svg> | |
| Execute Price Scout Sweep | |
| </button> | |
| <div id="loader-zone" class="loader-box"> | |
| <p style="color: var(--text-muted); font-size: 14px; margin-bottom: 15px; text-align: center;">⚡ Price Scout is assembling structural pricing matrices across real-time storage nodes...</p> | |
| <div style="height: 64px; width: 100%; margin-bottom: 12px;" class="skeleton"></div> | |
| <div style="height: 64px; width: 100%; margin-bottom: 12px;" class="skeleton"></div> | |
| <div style="height: 64px; width: 100%;" class="skeleton"></div> | |
| </div> | |
| </form> | |
| </div> | |
| {results_html} | |
| </body> | |
| </html> | |
| """ |