From 75516e621fb0c11c4b18310a1b061a5cb6d62140 2014-10-10 17:28:04 From: Bussonnier Matthias Date: 2014-10-10 17:28:04 Subject: [PATCH] Have /api return the IPython version return version as a string, to be consistent with other APIs. closes #6647 --- diff --git a/IPython/html/base/handlers.py b/IPython/html/base/handlers.py index 07bc059..768eaff 100644 --- a/IPython/html/base/handlers.py +++ b/IPython/html/base/handlers.py @@ -24,6 +24,8 @@ try: except ImportError: app_log = logging.getLogger() +import IPython + from IPython.config import Application from IPython.utils.path import filefind from IPython.utils.py3compat import string_types @@ -398,6 +400,13 @@ class FileFindHandler(web.StaticFileHandler): return super(FileFindHandler, self).validate_absolute_path(root, absolute_path) +class ApiVersionHandler(IPythonHandler): + + @json_errors + def get(self): + # not authenticated, so give as few info as possible + self.finish(json.dumps({"version":IPython.__version__})) + class TrailingSlashHandler(web.RequestHandler): """Simple redirect handler that strips trailing slashes @@ -456,5 +465,6 @@ file_path_regex = "%s/%s" % (path_regex, file_name_regex) default_handlers = [ - (r".*/", TrailingSlashHandler) + (r".*/", TrailingSlashHandler), + (r"api", ApiVersionHandler) ]