Created
June 30, 2016 00:49
-
-
Save anonymous/a871fde78792da38a559db959ba078ad to your computer and use it in GitHub Desktop.
RestfulAPI with Flask
This file contains 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
#!/usr/bin/env python | |
# -*- coding: UTF-8 -*- | |
# | |
from flask import Flask, jsonify | |
app = Flask(__name__) | |
tasks = [ | |
{ | |
'id': 1, | |
'title': '日用品を買ってくる', | |
'description': 'ミルク、チーズ、ピザ、フルーツ', | |
'done': False | |
}, | |
{ | |
'id': 2, | |
'title': 'Python の勉強', | |
'description': 'Python で Restful API を作る', | |
'done': False | |
} | |
] | |
@app.route('/') | |
def index(): | |
return 'Hello World!日本語' | |
@app.route('/todo/api/v1.0/tasks', methods=['GET']) | |
def get_tasks(): | |
return jsonify({'tasks': tasks}) | |
if __name__ == '__main__': | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment