82 lines
2.5 KiB
HTML
82 lines
2.5 KiB
HTML
<!doctype html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="utf-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
|
<title>Flask Calculator</title>
|
|
<style>
|
|
:root { color-scheme: light; }
|
|
body {
|
|
font-family: "Trebuchet MS", "Verdana", sans-serif;
|
|
margin: 0;
|
|
background: linear-gradient(135deg, #f7f0e8, #e6f2f5);
|
|
color: #1f2d33;
|
|
}
|
|
.wrap {
|
|
max-width: 720px;
|
|
margin: 8vh auto;
|
|
padding: 32px;
|
|
background: rgba(255, 255, 255, 0.9);
|
|
box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
|
|
border-radius: 18px;
|
|
}
|
|
h1 { margin: 0 0 12px; }
|
|
p { margin: 0 0 24px; color: #3d4c52; }
|
|
form {
|
|
display: grid;
|
|
gap: 12px;
|
|
grid-template-columns: 1fr 120px 1fr;
|
|
align-items: center;
|
|
}
|
|
input, select, button {
|
|
font-size: 16px;
|
|
padding: 10px 12px;
|
|
border-radius: 10px;
|
|
border: 1px solid #c4d3d9;
|
|
}
|
|
button {
|
|
grid-column: span 3;
|
|
background: #1f6f78;
|
|
color: white;
|
|
border: none;
|
|
cursor: pointer;
|
|
}
|
|
.result {
|
|
margin-top: 20px;
|
|
padding: 16px;
|
|
border-radius: 12px;
|
|
background: #f0f7f8;
|
|
}
|
|
.error { color: #b22020; }
|
|
@media (max-width: 640px) {
|
|
form { grid-template-columns: 1fr; }
|
|
button { grid-column: span 1; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="wrap">
|
|
<h1>Calculator</h1>
|
|
<p>Simple Flask calculator. Enter two numbers and choose an operation.</p>
|
|
<form method="post">
|
|
<input name="a" type="number" step="any" placeholder="First number" value="{{ a_val }}" required />
|
|
<select name="op">
|
|
<option value="+" {% if op == "+" %}selected{% endif %}>+</option>
|
|
<option value="-" {% if op == "-" %}selected{% endif %}>-</option>
|
|
<option value="*" {% if op == "*" %}selected{% endif %}>*</option>
|
|
<option value="/" {% if op == "/" %}selected{% endif %}>/</option>
|
|
</select>
|
|
<input name="b" type="number" step="any" placeholder="Second number" value="{{ b_val }}" required />
|
|
<button type="submit">Calculate</button>
|
|
</form>
|
|
|
|
{% if result is not none %}
|
|
<div class="result">Result: <strong>{{ result }}</strong></div>
|
|
{% endif %}
|
|
{% if error %}
|
|
<div class="result error">Error: {{ error }}</div>
|
|
{% endif %}
|
|
</div>
|
|
</body>
|
|
</html>
|