Created
November 27, 2016 22:55
-
-
Save gnschenker/6590096b173f10f521af235dbb6877c6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from flask import Flask, jsonify | |
app = Flask(__name__) | |
tasks = [ | |
{ | |
'id': 1, | |
'title': u'Buy groceries', | |
'description': u'Milk, Cheese, Pizza, Fruit, Tylenol', | |
'done': False | |
}, | |
{ | |
'id': 2, | |
'title': u'Learn Python', | |
'description': u'Need to find a good Python tutorial on the web', | |
'done': True | |
}, | |
{ | |
'id': 3, | |
'title': u'Explore IntelliJ', | |
'description': u'This Docker Integration plugin is awesome', | |
'done': False | |
} | |
] | |
@app.route('/api/numbers', methods=['GET']) | |
def get_numbers(): | |
print 'In get_numbers' | |
numbers = [1,2,3,4,5] | |
count = len(numbers) | |
return jsonify({'numbers': numbers, 'count': count}) | |
@app.route('/api/tasks', methods=['GET']) | |
def get_tasks(): | |
print 'In get_tasks' | |
t = tasks | |
task = {'id': 4, 'title': 'other stuff to do', 'done': True} | |
t.append(task) | |
return jsonify({'tasks': tasks}) | |
if __name__ == '__main__': | |
app.run(host='0.0.0.0', port=8080) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment