From 2b83352fbd9b99b414e12aac5cdb402fff1e07b5 Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Oct 2019 22:22:38 +0530 Subject: [PATCH 1/3] Added an index page --- routes/routes.py | 8 ++++---- templates/index.html | 8 ++++++++ 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 templates/index.html diff --git a/routes/routes.py b/routes/routes.py index 2374c2d..4d9e199 100644 --- a/routes/routes.py +++ b/routes/routes.py @@ -2,11 +2,11 @@ router = Blueprint("router", __name__) -@router.route("/check") -def check(): - return "Congratulations! Your app works. :)" +@router.route("/") +def start(): + return render_template('index.html') @router.route("/add", methods=["POST"]) def add(): # Add logic here - return \ No newline at end of file + return diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..cc08bbe --- /dev/null +++ b/templates/index.html @@ -0,0 +1,8 @@ + + +Index page + + +

This is a simple Flask Calculator

+ + \ No newline at end of file From f20441a6a629ed041764f9f123bd6470354cc65d Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 16 Oct 2019 22:25:44 +0530 Subject: [PATCH 2/3] Added library changes --- routes/routes.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/routes/routes.py b/routes/routes.py index 4d9e199..a8084fe 100644 --- a/routes/routes.py +++ b/routes/routes.py @@ -1,4 +1,4 @@ -from flask import Blueprint +from flask import Flask, render_template, request, Blueprint router = Blueprint("router", __name__) From 020794ef8cfdd85a6cd776c49818aedf35352b07 Mon Sep 17 00:00:00 2001 From: unknown Date: Thu, 17 Oct 2019 03:30:47 +0530 Subject: [PATCH 3/3] Added 4 routes and linked index to first route --- routes/routes.py | 31 ++++++++++++++++++++++++++++++- templates/index.html | 9 +++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/routes/routes.py b/routes/routes.py index a8084fe..815eac9 100644 --- a/routes/routes.py +++ b/routes/routes.py @@ -6,7 +6,36 @@ def start(): return render_template('index.html') + +#function to add @router.route("/add", methods=["POST"]) def add(): # Add logic here - return + n1 = int(request.form['num1']) + n2 = int(request.form['num2']) + return n1+n2 + + +#function to subtract +@router.route("/sub", methods=["POST"]) +def add(): + # Add logic here + n1 = int(request.form['num1']) + n2 = int(request.form['num2']) + return n1-n2 + +#function to multiply +@router.route("/mul", methods=["POST"]) +def add(): + # Add logic here + n1 = int(request.form['num1']) + n2 = int(request.form['num2']) + return n1*n2 + +#function to divide (integer division) +@router.route("/div", methods=["POST"]) +def add(): + # Add logic here + n1 = int(request.form['num1']) + n2 = int(request.form['num2']) + return n1//n2 diff --git a/templates/index.html b/templates/index.html index cc08bbe..bf2e5b0 100644 --- a/templates/index.html +++ b/templates/index.html @@ -4,5 +4,14 @@

This is a simple Flask Calculator

+

Enter Values of any two digits :

+
+Number 1 : +
+Number 2 : +
+ +
\ No newline at end of file