Skip to content

Instantly share code, notes, and snippets.

View staugur's full-sized avatar
:octocat:
Sorry, thank you!

Hiroshi.tao staugur

:octocat:
Sorry, thank you!
View GitHub Profile
@staugur
staugur / simplerequests.py
Created September 14, 2016 08:15
Based on the built-in function httplib requests similar to the python module similar to the URL module of the simple type of request
# coding:utf8
# taochengwei <[email protected]> @2016-09-13
__version__ = '0.1'
__doc__ = 'request url for json type'
import json, httplib, urllib, urlparse, logging
logging.basicConfig(
format='%(asctime)s %(levelname)s %(message)s',
@staugur
staugur / flask_access_log.py
Last active September 14, 2016 08:26
Flask access log
#每次返回数据中,带上响应头,包含API版本和本次请求的requestId,以及允许所有域跨域访问API, 记录访问日志.
@app.after_request
def add_header(response):
response.headers["X-Version"] = __version__
response.headers["Access-Control-Allow-Origin"] = "*"
logger.info(json.dumps({
"AccessLog": {
"status_code": response.status_code,
"method": request.method,