From 0c3b2cf042c84666138bc60e9aabd79844684e25 Mon Sep 17 00:00:00 2001 From: ajatgithub <64965487+ajatgithub@users.noreply.github.com> Date: Thu, 7 May 2020 19:08:24 +0530 Subject: [PATCH 01/11] Create app.yaml --- app.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 app.yaml diff --git a/app.yaml b/app.yaml new file mode 100644 index 0000000..b26a652 --- /dev/null +++ b/app.yaml @@ -0,0 +1,4 @@ +entrypoint: "gunicorn -b :$PORT main:app" +runtime: python +runtime_config: + python_version: 3 From 13af2180f4df661d20985f7b4cb429bf1f436480 Mon Sep 17 00:00:00 2001 From: ajatgithub <64965487+ajatgithub@users.noreply.github.com> Date: Thu, 7 May 2020 19:10:42 +0530 Subject: [PATCH 02/11] Create cloudbuild.yaml --- cloudbuild.yaml | 4 ++++ 1 file changed, 4 insertions(+) create mode 100644 cloudbuild.yaml diff --git a/cloudbuild.yaml b/cloudbuild.yaml new file mode 100644 index 0000000..e4a1483 --- /dev/null +++ b/cloudbuild.yaml @@ -0,0 +1,4 @@ +steps: +- name: "gcr.io/cloud-builders/gcloud" + args: ["app", "deploy"] +timeout: "1600s" From 09ecc9d98194030e816afd2b9cd93652d6f16193 Mon Sep 17 00:00:00 2001 From: ajatgithub <64965487+ajatgithub@users.noreply.github.com> Date: Thu, 7 May 2020 19:12:31 +0530 Subject: [PATCH 03/11] Create main.py --- main.py | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 main.py diff --git a/main.py b/main.py new file mode 100644 index 0000000..cfc58cc --- /dev/null +++ b/main.py @@ -0,0 +1,50 @@ +from flask import Flask, request, render_template + + +app = Flask(__name__) + +@app.route('/') +def index(): + return render_template("index.html") + + +@app.route('/', methods=['POST']) +def calculate(): + + # Validating blank inputs + try: + h = float(request.form['h']) + m = float(request.form['m']) + + hours = h + minutes = m + + # Validation for hours and minutes values + if 0 < h <= 12 and 0 <= m < 60: + + if (h == 12): + h = 0 + + # Calculating angles generated by movement of clock hands from 12 + hour_angle = 0.5 * (h * 60 + m) + minute_angle = 6 * m + + # Calculating difference between two angles of hours and minutes + angle = abs(hour_angle - minute_angle) + + # Finding smaller angle + angle = min(360 - angle, angle) + + return render_template("pass.html", h=hours, m=minutes, a=angle) + else: + w = "Oops.. Wrong Input !" + return render_template("pass.html", h=hours, m=minutes, w=w) + + except: + w = "Oops.. You submitted blank inputs !" + return render_template("pass.html", w=w) + + +if __name__ == '__main__': + app.run(debug=True) + From 86e41366201dac337cd11c0bf2411b7c9c77f227 Mon Sep 17 00:00:00 2001 From: ajatgithub <64965487+ajatgithub@users.noreply.github.com> Date: Thu, 7 May 2020 19:15:31 +0530 Subject: [PATCH 04/11] Create requirement.txt --- requirements.txt | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 requirements.txt diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..bf04841 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +Flask==1.1.0 +gunicorn==19.6.0 From d673fed91b6b5fcb75ff53804bf8c9830d5a4c85 Mon Sep 17 00:00:00 2001 From: ajatgithub <64965487+ajatgithub@users.noreply.github.com> Date: Thu, 7 May 2020 19:20:08 +0530 Subject: [PATCH 05/11] Create index.html --- templates/index.html | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 templates/index.html diff --git a/templates/index.html b/templates/index.html new file mode 100644 index 0000000..8c45656 --- /dev/null +++ b/templates/index.html @@ -0,0 +1,19 @@ + + +
+