From 4c1fad310a4b858ab6508d56d705aac43f940650 Mon Sep 17 00:00:00 2001 From: dr_domi Date: Sat, 2 May 2026 23:31:20 +0300 Subject: [PATCH] =?UTF-8?q?=D0=A3=D0=B1=D1=80=D0=B0=D0=BB=20=D0=B2=D1=81?= =?UTF-8?q?=D1=91=20=D0=BB=D0=B8=D1=88=D0=BD=D0=B5=D0=B5,=20=D0=BF=D0=BE?= =?UTF-8?q?=D0=BB=D0=BD=D0=BE=D1=81=D1=82=D1=8C=D1=8E=20=D0=BF=D0=B5=D1=80?= =?UTF-8?q?=D0=B5=D0=BF=D0=B8=D1=81=D0=B0=D0=BB=20=D0=BA=D0=BE=D0=B4=20?= =?UTF-8?q?=D0=B1=D0=B5=D0=B7=20=D0=BF=D0=B8=D1=82=D0=BE=D0=BD=D0=B0=20?= =?UTF-8?q?=D0=B8=20=D0=B2=D0=BE=D0=BE=D0=B1=D1=89=D0=B5=20=D0=B1=D0=B5?= =?UTF-8?q?=D0=B7=20=D0=B1=D1=8D=D0=BA=D0=B5=D0=BD=D0=B4=D0=B0.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app.py | 34 --------- index.html | 173 +++++++++++++++++++++++++++++++++++++++++++ static/script.js | 30 -------- static/style.css | 109 --------------------------- templates/index.html | 57 -------------- 5 files changed, 173 insertions(+), 230 deletions(-) delete mode 100755 app.py create mode 100644 index.html delete mode 100644 static/script.js delete mode 100644 static/style.css delete mode 100644 templates/index.html diff --git a/app.py b/app.py deleted file mode 100755 index 03dba53..0000000 --- a/app.py +++ /dev/null @@ -1,34 +0,0 @@ -#!/usr/bin/env python3 -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 new file mode 100644 index 0000000..5b8a286 --- /dev/null +++ b/index.html @@ -0,0 +1,173 @@ + + + + + + Калькулятор BMI + + + +
+

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

+
+ +
+
+ + + + + + + +
+ +
+
+ + + + + + + + \ No newline at end of file diff --git a/static/script.js b/static/script.js deleted file mode 100644 index 7c2e223..0000000 --- a/static/script.js +++ /dev/null @@ -1,30 +0,0 @@ -document.getElementById('bmi-form').addEventListener('submit', function(e) { - e.preventDefault(); - - const height = document.getElementById('height').value; - const weight = document.getElementById('weight').value; - const resultDiv = document.getElementById('result'); - - fetch('/calculate', { - method: 'POST', - headers: { 'Content-Type': 'application/json' }, - body: JSON.stringify({ height, weight }) - }) - .then(response => response.json()) - .then(data => { - if (data.error) { - resultDiv.style.display = 'block'; - resultDiv.style.color = '#cc0000'; - resultDiv.textContent = data.error; - } else { - resultDiv.style.display = 'block'; - resultDiv.style.color = '#003366'; - resultDiv.textContent = `Ваш BMI: ${data.bmi}`; - } - }) - .catch(() => { - resultDiv.style.display = 'block'; - resultDiv.textContent = 'Ошибка соединения с сервером.'; - resultDiv.style.color = '#cc0000'; - }); -}); \ No newline at end of file diff --git a/static/style.css b/static/style.css deleted file mode 100644 index b934cf4..0000000 --- a/static/style.css +++ /dev/null @@ -1,109 +0,0 @@ -/* Общие стили страницы */ -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 diff --git a/templates/index.html b/templates/index.html deleted file mode 100644 index a7d062d..0000000 --- a/templates/index.html +++ /dev/null @@ -1,57 +0,0 @@ - - - - - - Калькулятор BMI - - - - - -
- -

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

-
- - -
- -
-
- - - - - - - -
- - -
- -
-
-
- - - - - - - - - - - \ No newline at end of file