def post(self):
authenticated = False
if 'Authorization' in self.request.headers:
auth = self.request.headers['Authorization']
decoded = base64.b64decode(auth[6:])
authenticated = True
if authenticated:
self.response.out.write('OK')
else:
site = GetSite()
template_values = {}
template_values['site'] = site
template_values['message'] = "Authentication required"
path = os.path.join(os.path.dirname(__file__), 'tpl', 'api')
t = self.get_template(path,'error.json')
output = t.render(template_values)
self.set_status(401, 'Unauthorized')
self.set_header('Content-type', 'application/json')
self.set_header('WWW-Authenticate', 'Basic realm="' + site.domain + '"')
self.write(output)
# Replies
# /api/replies/show.json
评论列表
文章目录