Created
July 12, 2015 12:14
-
-
Save eagleon/c2149ec8bcd1dd7ab0f1 to your computer and use it in GitHub Desktop.
python mock
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
[ | |
{ | |
"id": 1, | |
"url": "http://abruzzi.github.com/2015/03/list-comprehension-in-python/", | |
"title": "Python中的 list comprehension 以及 generator", | |
"publicDate": "2015年3月20日" | |
}, | |
{ | |
"id": 2, | |
"url": "http://abruzzi.github.com/2015/03/build-monitor-script-based-on-inotify/", | |
"title": "使用inotify/fswatch构建自动监控脚本", | |
"publicDate": "2015年2月1日" | |
}, | |
{ | |
"id": 3, | |
"url": "http://abruzzi.github.com/2015/02/build-sample-application-by-using-underscore-and-jquery/", | |
"title": "使用underscore.js构建前端应用", | |
"publicDate": "2015年1月20日" | |
} | |
] |
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/python | |
# -*- coding:utf-8 -*- | |
from flask import Flask,Response | |
import codecs | |
app = Flask(__name__) | |
@app.route('/') | |
def index(): | |
resp = Response(codecs.open('data/list.json','r','utf-8').read()) | |
resp.headers['Content-Type'] = 'application/json;charset=UTF-8' | |
return resp | |
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