diff --git a/calculator/__init__.py b/calculator/__init__.py index db9d1f6..1fe898a 100755 --- a/calculator/__init__.py +++ b/calculator/__init__.py @@ -17,7 +17,27 @@ def ADD(): sum=a+b response = "sum of 2 numbers = " + str(sum) return response + +@app.route("/expo", methods=["POST"]) +def expo(): + jsonStr = request.get_json() + jsonObj = json.loads(jsonStr) + a=int(jsonObj['N1']) + b=int(jsonObj['N2']) + x=a + y=b + + ans=1; + while(b): + + if(b&1): ans = (ans*a) + a = (a*a) + b=b>>1 + + response = str(x) + "to the power " +str(y)+ " equals " +str(ans) + return response + @app.route("/xyz", methods=["POST"]) def XYZ(): jsonStr = request.get_json() @@ -29,15 +49,6 @@ def XYZ(): # Logic for function assigned to you as in pdf return 1 -def subtract(a,b): - jsonStr = request.get_json() - jsonObj = json.loads(jsonStr) - a=int(jsonObj['N1']) - b=int(jsonObj['N2']) - return a-b - - - if __name__== "__main__": - app.run() + app.run() \ No newline at end of file diff --git a/calculator/templates/InputOutput.html b/calculator/templates/InputOutput.html index 542075a..8603086 100755 --- a/calculator/templates/InputOutput.html +++ b/calculator/templates/InputOutput.html @@ -10,7 +10,8 @@