-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
29 lines (20 loc) · 714 Bytes
/
app.py
File metadata and controls
29 lines (20 loc) · 714 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
27
28
29
from flask import Flask, abort
from flask_restful import Api, Resource, reqparse
import engine as engine
app = Flask(__name__)
api = Api(app)
# Calculates expression and returns result
class Calc(Resource):
def post(self):
parser = reqparse.RequestParser()
parser.add_argument('expression', type=str, required=True)
args = parser.parse_args()
return engine.calc_json_expression(args['expression'])
# Returns a list of calc history from old to new
class History(Resource):
def get(self):
return engine.get_history()
api.add_resource(Calc, "/calc/")
api.add_resource(History, "/history/")
if __name__ == '__main__':
app.run(debug=True)