forked from miloopark/BostonHacksChallenge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
46 lines (35 loc) · 1.19 KB
/
app.py
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from flask import Flask, send_from_directory
from flask_restful import Api, Resource, reqparse
from flask_cors import CORS #comment this on deployment
app = Flask(__name__, static_url_path='', static_folder='frontend/build')
CORS(app) #comment this on deployment
api = Api(app)
@app.route("/")
def index():
return send_from_directory(app.static_folder,'index.html')
@app.route('/hello', methods=['GET'])
def helloWorld():
return {
'resultStatus': 'SUCCESS',
'message': "Hello Api Handler!"
}
@app.route('/update', methods=['POST'])
def updateTodo():
parser = reqparse.RequestParser()
parser.add_argument('type', type=str)
parser.add_argument('message', type=str)
args = parser.parse_args()
print(args)
request_type = args['type']
request_msg = args['message']
# currently just returning the request straight back
if request_msg:
ret_msg = "Your Message: {}".format(request_msg)
else:
ret_msg = "No Message"
if ret_msg:
ret_type = "Your Type: {}".format(request_type)
else:
ret_type = "No Type"
final_ret = {"status": "Success", "message": ret_msg, "type": ret_type}
return final_ret