Skip to content

Instantly share code, notes, and snippets.

Created June 30, 2016 01:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/bdfd5d928b23dfbc24006c14d9a6e964 to your computer and use it in GitHub Desktop.
Save anonymous/bdfd5d928b23dfbc24006c14d9a6e964 to your computer and use it in GitHub Desktop.
Modified flask simple api w/ jsonify
#!/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