-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
37 lines (28 loc) · 1 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
"""
This is the starting point of the Flask based web application. It exposes
all the necessary HTTP headers GET, PUT, POST, HEAD, DELETE.
"""
from flask import Flask, request
import resources
app = Flask(__name__)
@app.route('/keys', methods=['GET', 'POST', 'DELETE'])
def choreslist():
if request.method == 'GET':
return resources.get_chores()
elif request.method == 'POST':
chore = request.get_json()
return resources.make_a_new_chore(chore)
elif request.method == 'DELETE':
return resources.delete_all_chores()
@app.route('/keys/<title>', methods=['HEAD', 'PUT', 'DELETE'])
def chores(title):
if request.method == 'HEAD':
return resources.get_chore(title)
elif request.method == 'PUT':
chore = request.get_json()[title]
return resources.update_a_chore(title, chore)
elif request.method == 'DELETE':
return resources.delete_a_chore(title)
if __name__ == '__main__':
app.debug = True
app.run(host='0.0.0.0', port=5000)