Add Lesson 5 Task 2

This commit is contained in:
Stanislav Mykhailenko 2023-01-01 22:01:06 +02:00
parent a6623ce880
commit 54fc772c83
GPG key ID: 1E95E66A9C9D6A36
2 changed files with 29 additions and 0 deletions

View file

@ -0,0 +1,16 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Calculator</title>
</head>
<body>
<form action="">
<label for="result">Result: </label><br>
<input type="text" id="result" name="result" value="{{result|safe}}" disabled><br>
<label for="operation">Operation: </label><br>
<input type="text" id="operation" name="operation"><br>
<input type="submit" value="Submit">
</form>
</body>
</html>

View file

@ -0,0 +1,13 @@
from flask import Flask, render_template, redirect, request
from datetime import datetime
app = Flask("Calculator")
@app.route('/')
def index():
result = None
if 'operation' in request.args:
result = eval(request.args.get('operation'))
return render_template("index.html", result=result)
app.run(port=8080)