Skip to content

Commit

Permalink
Solved problem statement
Browse files Browse the repository at this point in the history
  • Loading branch information
ChetN343 committed Aug 23, 2023
1 parent 2cd13e5 commit 33c3d2f
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions server.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
from flask import Flask
from flask import Flask, request, jsonify
from dataclasses import dataclass


@dataclass
class Result:
result: int

app = Flask(__name__)


@app.route("/calculator/greeting", methods=['GET'])
def greeting():
return ''
return 'Hello world!'

@app.route("/calculator/add", methods=['POST'])
def add():
return ''
numbers = request.json
response = Result(numbers['first'] + numbers['second'])
return jsonify(response)

@app.route("/calculator/subtract", methods=['POST'])
def subtract():
return ''
numbers = request.json
response = Result(numbers['first'] - numbers['second'])
return jsonify(response)

if __name__ == '__main__':
app.run(port=8080,host='0.0.0.0')

0 comments on commit 33c3d2f

Please sign in to comment.