forked from pranavb-sahaj-ai/nano-demo-calculator-app
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathserver.py
More file actions
26 lines (21 loc) · 659 Bytes
/
server.py
File metadata and controls
26 lines (21 loc) · 659 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route("/calculator/greeting", methods=['GET'])
def greeting():
return 'Hello world!'
@app.route("/calculator/add", methods=['POST'])
def add():
data = request.get_json()
first = data['first']
second = data['second']
result = first + second
return jsonify({'result': result})
@app.route("/calculator/subtract", methods=['POST'])
def subtract():
data = request.get_json()
first = data['first']
second = data['second']
result = first - second
return jsonify({'result': result})
if __name__ == '__main__':
app.run(port=8080, host='0.0.0.0')