diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..66544f0 Binary files /dev/null and b/.DS_Store differ diff --git a/circle.py b/circle.py new file mode 100644 index 0000000..b517c00 --- /dev/null +++ b/circle.py @@ -0,0 +1,13 @@ +import math + +class Circle: + def __init__(self,radius): + self.radius = radius + + def perimeter(self): + return 2 * math.pi * self.radius + + def area(self): + return math.pi * (self.radius ** 2) + + diff --git a/flask_app.py b/flask_app.py index 8897fa2..61c3cad 100644 --- a/flask_app.py +++ b/flask_app.py @@ -2,6 +2,8 @@ from helper import perform_calculation, convert_to_float +from circle import Circle + app = Flask(__name__) # create the instance of the flask class @@ -38,3 +40,14 @@ def calculate(): return render_template('calculator.html', printed_result="You cannot divide by zero") return render_template('calculator.html') + + +@app.route('/circle', methods=['GET', 'POST']) +def calculate_circle(): + if request.method == 'POST': + radius = float(request.form['radius']) + circle = Circle(radius) + perimeter = circle.perimeter() + area = circle.area() + return render_template('radius.html', perimeter=perimeter, area=area) + return render_template('radius.html') diff --git a/templates/layout.html b/templates/layout.html index 8de2e62..7986008 100644 --- a/templates/layout.html +++ b/templates/layout.html @@ -12,6 +12,7 @@
Perimeter: {{ perimeter }}
+Area: {{ area }}
+