Created
June 30, 2016 01:19
-
-
Save anonymous/bdfd5d928b23dfbc24006c14d9a6e964 to your computer and use it in GitHub Desktop.
Modified flask simple api w/ jsonify
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__) | |
app.config['JSON_AS_ASCII'] = False // <-- これ | |
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