-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathapp.py
More file actions
31 lines (21 loc) · 719 Bytes
/
app.py
File metadata and controls
31 lines (21 loc) · 719 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
30
31
import math
from flask import Flask, request, jsonify
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
@app.route('/sqrt', methods=['GET'])
def sqrt():
if 'value' not in request.args:
return 'No value in request', 400
response = {'result': math.sqrt(float(request.args['value']))}
return jsonify(response)
@app.route('/sum', methods=['GET'])
def add_message_of_sum():
if 'value' not in request.args:
return 'No value in request', 400
total = sum([int(x) for x in request.args['value'].split('_')])
response = {'result': total, 'Message': 'Evthg is fuckin awesome'}
return jsonify(response)
if __name__ == '__main__':
app.run()