From 54fc772c83ba8aff13793d7a3766743f92c97dd0 Mon Sep 17 00:00:00 2001 From: Stanislav Mykhailenko Date: Sun, 1 Jan 2023 22:01:06 +0200 Subject: [PATCH] Add Lesson 5 Task 2 --- Lesson_5/Task 2/templates/index.html | 16 ++++++++++++++++ Lesson_5/Task 2/webserver.py | 13 +++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Lesson_5/Task 2/templates/index.html create mode 100644 Lesson_5/Task 2/webserver.py diff --git a/Lesson_5/Task 2/templates/index.html b/Lesson_5/Task 2/templates/index.html new file mode 100644 index 0000000..0bcf8de --- /dev/null +++ b/Lesson_5/Task 2/templates/index.html @@ -0,0 +1,16 @@ + + + + Calculator + + +
+
+
+
+
+ +
+ + + diff --git a/Lesson_5/Task 2/webserver.py b/Lesson_5/Task 2/webserver.py new file mode 100644 index 0000000..6688332 --- /dev/null +++ b/Lesson_5/Task 2/webserver.py @@ -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)