From d9e05ea8e0828a844cf5ea67e1f1f1f0462cd0fb Mon Sep 17 00:00:00 2001 From: dr_domi Date: Sat, 2 May 2026 21:43:38 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9F=D0=BE=D1=87=D1=82=D0=B8=20=D0=B2=D1=81?= =?UTF-8?q?=D1=91=20=D0=B4=D0=BE=D0=BF=D0=B8=D1=81=D0=B0=D0=BD=D0=BE,=20?= =?UTF-8?q?=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82=20=D0=B4=D0=BB=D1=8F=20?= =?UTF-8?q?=D1=82=D0=BE=D0=B3=D0=BE,=20=D1=87=D1=82=D0=BE=D0=B1=D1=8B=20?= =?UTF-8?q?=D0=B2=D1=8B=D0=B4=D0=B5=D0=BB=D0=B8=D1=82=D1=8C=20=D0=B2=D0=B5?= =?UTF-8?q?=D1=82=D0=BA=D1=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 33 ++++++++++++++++ index.html | 57 ++++++++++++++++++++++++++++ styles.css | 109 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 199 insertions(+) create mode 100644 app.py diff --git a/app.py b/app.py new file mode 100644 index 0000000..a794957 --- /dev/null +++ b/app.py @@ -0,0 +1,33 @@ +from flask import Flask, request, jsonify, render_template + +app = Flask(__name__) + +def calculate_bmi(height, weight): + return round(weight / (height ** 2), 2) + +def user_input_check(height, weight): + if height <= 0 or height > 3: + return "Рост должен быть больше 0 и не превышать 3 метра." + if weight <= 0 or weight > 200: + return "Вес должен быть больше 0 и не превышать 200 кг." + return None + +@app.route('/') +def index(): + return render_template('index.html') + +@app.route('/calculate', methods=['POST']) +def calculate(): + data = request.get_json() + height = float(data['height']) + weight = float(data['weight']) + + error = user_input_check(height, weight) + if error: + return jsonify({'error': error}), 400 + + bmi = calculate_bmi(height, weight) + return jsonify({'bmi': bmi}) + +if __name__ == '__main__': + app.run(debug=True) \ No newline at end of file diff --git a/index.html b/index.html index e69de29..155c056 100644 --- a/index.html +++ b/index.html @@ -0,0 +1,57 @@ + + + + + + Калькулятор BMI + + + + + +
+ +

Калькулятор индекса массы тела (BMI)

+
+ + +
+ +
+
+ + + + + + + +
+ + +
+ +
+
+
+ + + + + + + + + + + \ No newline at end of file diff --git a/styles.css b/styles.css index e69de29..b934cf4 100644 --- a/styles.css +++ b/styles.css @@ -0,0 +1,109 @@ +/* Общие стили страницы */ +body { + font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; + background-color: #e6f7ff; /* Светло-голубой фон */ + color: #003366; /* Тёмно-синий текст для контраста */ + margin: 0; + padding: 0; + line-height: 1.6; +} + +/* Шапка сайта */ +header { + background-color: #b3e0ff; /* Более тёмный голубой */ + padding: 20px; + text-align: center; + box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1); +} + +header h1 { + margin: 0; + font-size: 28px; + color: #003366; +} + +/* Основное содержимое */ +main { + max-width: 600px; + margin: 30px auto; + padding: 20px; + background-color: #d9f0ff; /* Светло-голубой блок */ + border-radius: 10px; + box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1); +} + +/* Форма ввода */ +form label { + display: block; + margin-top: 15px; + font-weight: bold; + color: #003366; +} + +form input[type="text"] { + width: 100%; + padding: 10px; + margin-top: 5px; + border: 1px solid #99d6ff; + border-radius: 5px; + font-size: 16px; + box-sizing: border-box; +} + +form button { + margin-top: 20px; + padding: 12px 20px; + background-color: #0066cc; /* Синий цвет кнопки */ + color: white; + border: none; + border-radius: 5px; + font-size: 16px; + cursor: pointer; + transition: background-color 0.3s; +} + +form button:hover { + background-color: #004d99; /* Темнее при наведении */ +} + +/* Блок результата */ +#result { + margin-top: 20px; + padding: 15px; + background-color: #cce6ff; + border-radius: 5px; + font-size: 18px; + font-weight: bold; + text-align: center; + display: none; /* Скрыто до расчёта */ +} + +/* Дополнительная информация (шкала BMI) */ +aside { + max-width: 600px; + margin: 20px auto; + padding: 15px; + background-color: #c2e0ff; + border-radius: 8px; + font-size: 14px; +} + +aside h3 { + margin-top: 0; + color: #003366; +} + +aside ul { + margin: 10px 0; + padding-left: 20px; +} + +/* Подвал */ +footer { + text-align: center; + padding: 20px; + background-color: #b3e0ff; + color: #003366; + font-size: 14px; + margin-top: 40px; +} \ No newline at end of file