def retrieveIPs():
""" Retrieve IPs from ElasticSearch and return formatted XML or JSON with IPs """
if request.args.get('out') and request.args.get('out') == 'json':
getCacheResult = getCache(request.url, "url")
if getCacheResult is not False:
return jsonify(getCacheResult)
else:
returnResult = formatBadIP(
queryBadIPs(app.config['BADIPTIMESPAN'], checkCommunityIndex(request)), 'json')
setCache(request.url, returnResult, 60, "url")
return jsonify(returnResult)
else:
getCacheResult = getCache(request.url, "url")
if getCacheResult is not False:
return Response(getCacheResult, mimetype='text/xml')
else:
returnResult = formatBadIP(
queryBadIPs(app.config['BADIPTIMESPAN'], checkCommunityIndex(request)), 'xml')
setCache(request.url, returnResult, 60, "url")
return Response(returnResult, mimetype='text/xml')
# Routes with JSON output
评论列表
文章目录