Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

adding a stats endpoint for monitoring

  • Loading branch information...
commit 08aa897bf833fdd32825b3e2cf190bec773d2b44 1 parent 9e46433
Jeff Lindsay progrium authored
Showing with 9 additions and 0 deletions.
  1. +8 −0 requestbin/api.py
  2. +1 −0  requestbin/web.py
8 requestbin/api.py
View
@@ -18,3 +18,11 @@ def bins():
resp.headers['Content-Type'] = 'application/json'
resp.headers['Access-Control-Allow-Origin'] = '*'
return resp
+
+@app.endpoint('api.stats')
+def stats():
+ service = app.config['service']
+ stats = {'bin_count': len(service.bins)}
+ resp = make_response(json.dumps(stats), 200)
+ resp.headers['Content-Type'] = 'application/json'
+ return resp
1  requestbin/web.py
View
@@ -9,6 +9,7 @@
app.add_url_rule('/docs/<name>', 'views.docs')
app.add_url_rule('/api/v1/bins', 'api.bins', methods=['POST'])
+app.add_url_rule('/api/v1/stats', 'api.stats')
app.add_url_rule('/favicon.ico', view_func=lambda: redirect('/static/favicon.ico'))
app.add_url_rule('/robots.txt', view_func=lambda: redirect('/static/robots.txt'))
Please sign in to comment.
Something went wrong with that request. Please try again.