From 34ffe46fa0474a47bc737669ccd58fe036e3a033 Mon Sep 17 00:00:00 2001 From: Aldo Cortesi Date: Thu, 7 Jun 2012 11:39:37 +1200 Subject: Add /api/info, returning general info on the running pathod daemon. --- libpathod/pathod.py | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'libpathod/pathod.py') 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 -- cgit v1.2.3