Spaces:
Sleeping
Sleeping
Download app.py from ENLYAS/fashiositeexc: direct link, hf CLI and curl.
- Browser
- Download file 13.4 kB
-
https://huggingface.co/spaces/ENLYAS/fashiositeexc/resolve/main/app.py
- Command line
-
hf download hf://spaces/ENLYAS/fashiositeexc/app.py
-
curl -L -o app.py https://huggingface.co/spaces/ENLYAS/fashiositeexc/resolve/main/app.py
13.4 kB
| import gradio as gr | |
| import random | |
| from datetime import datetime | |
| # Fashion data | |
| FASHION_CATEGORIES = ["Dresses", "Tops", "Bottoms", "Outerwear", "Accessories", "Shoes"] | |
| PRODUCTS = [ | |
| {"id": 1, "name": "Elegant Evening Dress", "category": "Dresses", "price": 189.99, "rating": 4.8, "image": "π", "description": "Stunning floor-length gown perfect for special occasions"}, | |
| {"id": 2, "name": "Casual Summer Top", "category": "Tops", "price": 45.99, "rating": 4.5, "image": "π", "description": "Breathable cotton blend for everyday comfort"}, | |
| {"id": 3, "name": "Designer Jeans", "category": "Bottoms", "price": 129.99, "rating": 4.7, "image": "π", "description": "Premium denim with perfect fit and stretch"}, | |
| {"id": 4, "name": "Leather Jacket", "category": "Outerwear", "price": 299.99, "rating": 4.9, "image": "π§₯", "description": "Genuine leather with classic biker style"}, | |
| {"id": 5, "name": "Statement Necklace", "category": "Accessories", "price": 79.99, "rating": 4.6, "image": "π", "description": "Bold piece to elevate any outfit"}, | |
| {"id": 6, "name": "Ankle Boots", "category": "Shoes", "price": 159.99, "rating": 4.8, "image": "π’", "description": "Versatile boots for all seasons"}, | |
| {"id": 7, "name": "Silk Blouse", "category": "Tops", "price": 89.99, "rating": 4.7, "image": "π", "description": "Luxurious silk for professional elegance"}, | |
| {"id": 8, "name": "Maxi Skirt", "category": "Bottoms", "price": 69.99, "rating": 4.4, "image": "π", "description": "Flowing silhouette for effortless style"}, | |
| ] | |
| FASHION_TRENDS = [ | |
| {"trend": "Sustainable Fashion", "description": "Eco-friendly materials and ethical production", "popularity": "95%"}, | |
| {"trend": "Y2K Revival", "description": "Early 2000s aesthetics making a comeback", "popularity": "88%"}, | |
| {"trend": "Oversized Blazers", "description": "Power dressing with relaxed silhouettes", "popularity": "92%"}, | |
| {"trend": "Chunky Sneakers", "description": "Bold footwear for street style", "popularity": "85%"}, | |
| ] | |
| REVIEWS = [ | |
| {"user": "Sarah M.", "rating": 5, "comment": "Absolutely love this dress! Perfect fit and amazing quality."}, | |
| {"user": "Jessica L.", "rating": 4, "comment": "Great style, runs slightly small. Order one size up."}, | |
| {"user": "Emma K.", "rating": 5, "comment": "Best purchase ever! Received so many compliments."}, | |
| {"user": "Olivia R.", "rating": 4, "comment": "Beautiful piece, fast shipping, will buy again."}, | |
| ] | |
| class FashionApp: | |
| def __init__(self): | |
| self.cart = [] | |
| self.wishlist = [] | |
| def get_products(self, category="All"): | |
| if category == "All": | |
| return PRODUCTS | |
| return [p for p in PRODUCTS if p["category"] == category] | |
| def add_to_cart(self, product_id): | |
| product = next((p for p in PRODUCTS if p["id"] == product_id), None) | |
| if product: | |
| self.cart.append(product) | |
| return f"β Added {product['name']} to cart!" | |
| return "β Product not found" | |
| def add_to_wishlist(self, product_id): | |
| product = next((p for p in PRODUCTS if p["id"] == product_id), None) | |
| if product: | |
| self.wishlist.append(product) | |
| return f"β€οΈ Added {product['name']} to wishlist!" | |
| return "β Product not found" | |
| def get_cart_total(self): | |
| return sum(p["price"] for p in self.cart) | |
| def get_cart_display(self): | |
| if not self.cart: | |
| return "Your cart is empty π" | |
| items = "\n".join([f"β’ {p['image']} {p['name']} - ${p['price']:.2f}" for p in self.cart]) | |
| return f"π Your Cart:\n{items}\n\nπ° Total: ${self.get_cart_total():.2f}" | |
| def get_wishlist_display(self): | |
| if not self.wishlist: | |
| return "Your wishlist is empty β€οΈ" | |
| items = "\n".join([f"β’ {p['image']} {p['name']} - ${p['price']:.2f}" for p in self.wishlist]) | |
| return f"β€οΈ Your Wishlist:\n{items}" | |
| def style_recommendation(self, occasion, season, style_preference): | |
| recommendations = [] | |
| if occasion == "Work": | |
| recommendations.append("π Tailored blazer with crisp white shirt") | |
| recommendations.append("π High-waisted trousers in neutral tones") | |
| elif occasion == "Casual": | |
| recommendations.append("π Relaxed fit t-shirt with denim") | |
| recommendations.append("π Comfortable sneakers") | |
| elif occasion == "Evening": | |
| recommendations.append("π Little black dress or elegant jumpsuit") | |
| recommendations.append("π Statement jewelry") | |
| elif occasion == "Date Night": | |
| recommendations.append("π Flattering midi dress") | |
| recommendations.append("π Heels or stylish boots") | |
| if season == "Spring": | |
| recommendations.append("πΈ Pastel colors and floral prints") | |
| elif season == "Summer": | |
| recommendations.append("βοΈ Lightweight fabrics and bright colors") | |
| elif season == "Fall": | |
| recommendations.append("π Layering with warm tones") | |
| elif season == "Winter": | |
| recommendations.append("βοΈ Cozy knits and statement coats") | |
| if style_preference == "Classic": | |
| recommendations.append("β¨ Timeless pieces that never go out of style") | |
| elif style_preference == "Trendy": | |
| recommendations.append("π₯ Latest runway-inspired looks") | |
| elif style_preference == "Bohemian": | |
| recommendations.append("πΏ Flowing fabrics and earthy tones") | |
| elif style_preference == "Minimalist": | |
| recommendations.append("βͺ Clean lines and monochromatic palette") | |
| return "\n\n".join(recommendations) | |
| def checkout(self): | |
| if not self.cart: | |
| return "β Your cart is empty! Add items before checkout." | |
| total = self.get_cart_total() | |
| self.cart = [] | |
| return f"π Thank you for your order!\n\nTotal: ${total:.2f}\n\nYour order will be processed shortly.\n\nTracking number: FSH{random.randint(10000, 99999)}" | |
| def clear_cart(self): | |
| self.cart = [] | |
| return "ποΈ Cart cleared!" | |
| app = FashionApp() | |
| with gr.Blocks(theme=gr.themes.Soft(), title="LUXE Fashion Boutique") as demo: | |
| gr.Markdown("""# β¨ LUXE Fashion Boutique β¨ | |
| ### Your destination for exceptional style and timeless elegance""") | |
| with gr.Tabs(): | |
| # Home Tab | |
| with gr.TabItem("π Home"): | |
| gr.Markdown("## π Featured Collection") | |
| with gr.Row(): | |
| for i, product in enumerate(PRODUCTS[:4]): | |
| with gr.Column(): | |
| gr.Markdown(f"### {product['image']} {product['name']}") | |
| gr.Markdown(f"**${product['price']:.2f}** β {product['rating']}") | |
| gr.Markdown(f"{product['description']}") | |
| add_btn = gr.Button("Add to Cart", variant="primary") | |
| add_btn.click(fn=app.add_to_cart, inputs=gr.Number(value=product['id'], visible=False), outputs=gr.Textbox(label="Status")) | |
| gr.Markdown("## π₯ Current Trends") | |
| with gr.Row(): | |
| for trend in FASHION_TRENDS: | |
| with gr.Column(): | |
| gr.Markdown(f"### {trend['trend']}") | |
| gr.Markdown(f"{trend['description']}") | |
| gr.Markdown(f"**Popularity: {trend['popularity']}**") | |
| # Shop Tab | |
| with gr.TabItem("ποΈ Shop"): | |
| category_dropdown = gr.Dropdown( | |
| choices=["All"] + FASHION_CATEGORIES, | |
| value="All", | |
| label="Filter by Category" | |
| ) | |
| product_display = gr.Markdown() | |
| def update_products(category): | |
| products = app.get_products(category) | |
| result = "## π¦ Available Products\n\n" | |
| for p in products: | |
| result += f"### {p['image']} {p['name']}\n" | |
| result += f"**${p['price']:.2f}** | β {p['rating']} | {p['category']}\n" | |
| result += f"{p['description']}\n\n" | |
| return result | |
| category_dropdown.change(fn=update_products, inputs=category_dropdown, outputs=product_display) | |
| product_display.value = update_products("All") | |
| with gr.Row(): | |
| product_id_input = gr.Number(label="Product ID", precision=0) | |
| add_btn = gr.Button("Add to Cart", variant="primary") | |
| wishlist_btn = gr.Button("Add to Wishlist", variant="secondary") | |
| add_btn.click(fn=app.add_to_cart, inputs=product_id_input, outputs=gr.Textbox(label="Status")) | |
| wishlist_btn.click(fn=app.add_to_wishlist, inputs=product_id_input, outputs=gr.Textbox(label="Status")) | |
| # Style Quiz Tab | |
| with gr.TabItem("π« Style Quiz"): | |
| gr.Markdown("## Get Personalized Style Recommendations") | |
| with gr.Row(): | |
| occasion = gr.Dropdown( | |
| choices=["Work", "Casual", "Evening", "Date Night"], | |
| label="Occasion" | |
| ) | |
| season = gr.Dropdown( | |
| choices=["Spring", "Summer", "Fall", "Winter"], | |
| label="Season" | |
| ) | |
| style_pref = gr.Dropdown( | |
| choices=["Classic", "Trendy", "Bohemian", "Minimalist"], | |
| label="Style Preference" | |
| ) | |
| recommend_btn = gr.Button("Get Recommendations", variant="primary") | |
| recommendation_output = gr.Textbox(label="Your Personalized Recommendations", lines=8) | |
| recommend_btn.click( | |
| fn=app.style_recommendation, | |
| inputs=[occasion, season, style_pref], | |
| outputs=recommendation_output | |
| ) | |
| # Cart Tab | |
| with gr.TabItem("π Cart"): | |
| cart_display = gr.Textbox(label="Shopping Cart", lines=10) | |
| def refresh_cart(): | |
| return app.get_cart_display() | |
| with gr.Row(): | |
| checkout_btn = gr.Button("Checkout", variant="primary") | |
| clear_btn = gr.Button("Clear Cart", variant="stop") | |
| checkout_output = gr.Textbox(label="Order Status", lines=5) | |
| checkout_btn.click(fn=app.checkout, outputs=checkout_output) | |
| clear_btn.click(fn=app.clear_cart, outputs=gr.Textbox(label="Status")) | |
| demo.load(fn=refresh_cart, outputs=cart_display) | |
| # Wishlist Tab | |
| with gr.TabItem("β€οΈ Wishlist"): | |
| wishlist_display = gr.Textbox(label="Your Wishlist", lines=10) | |
| def refresh_wishlist(): | |
| return app.get_wishlist_display() | |
| demo.load(fn=refresh_wishlist, outputs=wishlist_display) | |
| # Reviews Tab | |
| with gr.TabItem("β Reviews"): | |
| gr.Markdown("## Customer Reviews") | |
| for review in REVIEWS: | |
| with gr.Group(): | |
| gr.Markdown(f"**{review['user']}** - {'β' * review['rating']}") | |
| gr.Markdown(f"_{review['comment']}_") | |
| gr.Markdown("## Write a Review") | |
| with gr.Row(): | |
| review_name = gr.Textbox(label="Your Name", placeholder="Enter your name") | |
| review_rating = gr.Slider(minimum=1, maximum=5, step=1, label="Rating", value=5) | |
| review_text = gr.Textbox(label="Your Review", placeholder="Share your experience...") | |
| submit_review = gr.Button("Submit Review", variant="primary") | |
| review_status = gr.Textbox(label="Status") | |
| def submit_review_fn(name, rating, text): | |
| if name and text: | |
| return f"β Thank you {name}! Your review has been submitted." | |
| return "β Please fill in all fields." | |
| submit_review.click( | |
| fn=submit_review_fn, | |
| inputs=[review_name, review_rating, review_text], | |
| outputs=review_status | |
| ) | |
| # About Tab | |
| with gr.TabItem("βΉοΈ About"): | |
| gr.Markdown("""## About LUXE Fashion Boutique | |
| ### Our Story | |
| Founded in 2024, LUXE Fashion Boutique is dedicated to bringing you the finest fashion pieces from around the world. We believe that exceptional style should be accessible to everyone. | |
| ### Our Values | |
| - β¨ **Quality First**: Every piece is carefully curated for excellence | |
| - π± **Sustainability**: We partner with eco-conscious brands | |
| - π **Customer Care**: Your satisfaction is our priority | |
| - π¨ **Innovation**: Always ahead of the trends | |
| ### Contact Us | |
| π§ support@luxefashion.com\nπ± 1-800-LUXE-STYLE\nπ 123 Fashion Avenue, New York, NY | |
| ### Shipping & Returns | |
| - Free shipping on orders over $100 | |
| - 30-day return policy | |
| - Express shipping available | |
| ### Follow Us | |
| πΈ @luxefashionboutique""") | |
| if __name__ == "__main__": | |
| demo.launch(server_name="0.0.0.0", server_port=7860) | |