NaturalGlow / app.py
Vale33Ort's picture
Create app.py
68f3b27 verified
Raw
History Blame Contribute Delete
4.52 kB
import os
from flask import Flask, request, render_template_string
app = Flask(__name__)
SKIN_DATA = {
"Normal": {
"makeup": "Natural look with light foundation and subtle blush.",
"products": "Gentle cleanser, hydrating moisturizer, and SPF protection."
},
"Dry": {
"makeup": "Hydrating foundation, cream blush, and dewy finish products.",
"products": "Hydrating cleanser, intense moisturizer, nourishing oils."
},
"Oily": {
"makeup": "Mattifying foundation, powder blush, and oil-control products.",
"products": "Foaming cleanser, oil-free moisturizer, mattifying primers."
},
"Combination": {
"makeup": "Balanced foundation for T-zone and cheeks, versatile blush.",
"products": "Gentle cleanser, balancing moisturizer, lightweight sunscreen."
},
"Sensitive": {
"makeup": "Hypoallergenic and fragrance-free makeup products.",
"products": "Fragrance-free cleanser, soothing moisturizer, calming serums."
}
}
HTML_TEMPLATE = '''
<!doctype html>
<html lang="es">
<head>
<meta charset="UTF-8">
<title>Recomendación de Maquillaje y Cuidado de Piel</title>
<style>
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
background: linear-gradient(135deg, #fceabb, #f8b500);
margin: 0;
padding: 0;
display: flex;
justify-content: center;
align-items: flex-start;
height: 100vh;
color: #4b3b2b;
}
.container {
background: #fff8e1;
padding: 2rem 3rem;
margin-top: 3rem;
border-radius: 12px;
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
max-width: 500px;
width: 90%;
}
h1 {
text-align: center;
margin-bottom: 1rem;
color: #d35400;
text-shadow: 1px 1px 2px #b34700;
}
label {
font-weight: 600;
display: block;
margin-bottom: 0.5rem;
}
select, button {
width: 100%;
padding: 0.75rem;
border-radius: 6px;
border: 1px solid #bbb;
font-size: 1rem;
margin-bottom: 1.5rem;
transition: border-color 0.3s;
}
select:focus, button:hover {
outline: none;
border-color: #d35400;
cursor: pointer;
}
.result {
background: #fff3cd;
border: 1px solid #ffeeba;
border-radius: 8px;
padding: 1rem 1.5rem;
color: #856404;
}
.footer {
text-align: center;
font-size: 0.85rem;
color: #aaa;
margin-top: 2rem;
}
</style>
</head>
<body>
<div class="container">
<h1>¿Cuál es tu tipo de piel?</h1>
<form method="post" action="/">
<label for="skin_type">Selecciona tu tipo de piel:</label>
<select id="skin_type" name="skin_type" required>
<option value="" disabled {% if not selected %}selected{% endif %}>Elige una opción</option>
{% for key in skin_types %}
<option value="{{ key }}" {% if selected == key %}selected{% endif %}>{{ key }}</option>
{% endfor %}
</select>
<button type="submit">Ver Recomendaciones</button>
</form>
{% if recommendations %}
<div class="result">
<h2>Recomendaciones para piel {{ selected }}:</h2>
<p><strong>Maquillaje:</strong> {{ recommendations.makeup }}</p>
<p><strong>Cuidado de la piel:</strong> {{ recommendations.products }}</p>
</div>
{% endif %}
</div>
<div class="footer">
&copy; 2024 Recomendador de Maquillaje y Cuidado de Piel
</div>
</body>
</html>
'''
@app.route('/', methods=['GET', 'POST'])
def home():
selected = None
recommendations = None
if request.method == 'POST':
selected = request.form.get('skin_type')
if selected in SKIN_DATA:
recommendations = SKIN_DATA[selected]
return render_template_string(
HTML_TEMPLATE,
skin_types=SKIN_DATA.keys(),
selected=selected,
recommendations=recommendations
)
if __name__ == '__main__':
app.run(host='0.0.0.0', port=int(os.environ.get("PORT", 5000)), debug=True)