def pushit(path):
# no path; return a list of avaliable archives
if path == '':
#resp = jsonify(listArchives_server(handlers))
#resp.status_code = 200
return render_template('index.html')
#return resp
# get request with path
elif (path == 'api'):
resp = jsonify(listArchives_server(handlers))
resp.status_code = 200
return resp
elif (path == "ajax-loader.gif"):
return render_template('ajax-loader.gif')
else:
try:
# get the args passed to push function like API KEY if provided
PUSH_ARGS = {}
for k in request.args.keys():
PUSH_ARGS[k] = request.args[k]
s = str(path).split('/', 1)
arc_id = s[0]
URI = s[1]
if 'herokuapp.com' in request.host:
PUSH_ARGS['from_heroku'] = True
# To push into archives
resp = {"results": push(URI, arc_id, PUSH_ARGS)}
if len(resp["results"]) == 0:
return bad_request()
else:
# what to return
resp = jsonify(resp)
resp.status_code = 200
return resp
except Exception as e:
pass
return bad_request()
评论列表
文章目录