diff options
author | Aldo Cortesi <aldo@nullcube.com> | 2012-06-07 11:39:37 +1200 |
---|---|---|
committer | Aldo Cortesi <aldo@nullcube.com> | 2012-06-07 11:39:37 +1200 |
commit | 34ffe46fa0474a47bc737669ccd58fe036e3a033 (patch) | |
tree | 14cf0e950055c2a493320cf453a499467c902fed /libpathod/pathod.py | |
parent | 14b2a69d2119d8b9d0260aa31190fc7869b45e05 (diff) | |
download | mitmproxy-34ffe46fa0474a47bc737669ccd58fe036e3a033.tar.gz mitmproxy-34ffe46fa0474a47bc737669ccd58fe036e3a033.tar.bz2 mitmproxy-34ffe46fa0474a47bc737669ccd58fe036e3a033.zip |
Add /api/info, returning general info on the running pathod daemon.
Diffstat (limited to 'libpathod/pathod.py')
-rw-r--r-- | libpathod/pathod.py | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/libpathod/pathod.py b/libpathod/pathod.py index 9b0f4ac1..6012abc1 100644 --- a/libpathod/pathod.py +++ b/libpathod/pathod.py @@ -1,6 +1,6 @@ import urllib, pprint import tornado.web, tornado.template, tornado.ioloop, tornado.httpserver -import rparse, utils +import rparse, utils, version class APILog(tornado.web.RequestHandler): @@ -24,6 +24,15 @@ class APIShutdown(tornado.web.RequestHandler): self.write("OK") +class APIInfo(tornado.web.RequestHandler): + def get(self): + self.write( + dict( + version = version.IVERSION + ) + ) + + class _Page(tornado.web.RequestHandler): def render(self, name, **kwargs): tornado.web.RequestHandler.render(self, name + ".html", **kwargs) @@ -141,6 +150,7 @@ class PathodApp(tornado.web.Application): (r"/help", Help), (r"/preview", Preview), (r"/api/shutdown", APIShutdown), + (r"/api/info", APIInfo), (r"/api/log", APILog), (r"/api/log/clear", APILogClear), (r"/p/.*", RequestPathod, settings), @@ -228,7 +238,7 @@ def make_app(staticdir=None, anchors=()): def make_server(application, port, address, ssl_options): """ - Returns a (server, port) tuple. + Returns a (server, port) tuple. The returned port will match the passed port, unless the passed port was 0. In that case, an arbitrary empty port will be bound to, and this |