IPython Documentation

Table Of Contents

Previous topic

Module: html.auth.logout

Next topic

Module: html.base.zmqhandlers

This Page

Note

This documentation is for a development version of IPython. There may be significant differences from the latest stable release.

Module: html.base.handlers

Base Tornado handlers for the notebook server.

8 Classes

class IPython.html.base.handlers.AuthenticatedHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

A RequestHandler with an authenticated user.

logged_in

Is a user currently logged in?

login_available

May a user proceed to log in?

This returns True if login capability is available, irrespective of whether the user is already logged in or not.

password

our password

class IPython.html.base.handlers.IPythonHandler(application, request, **kwargs)

Bases: IPython.html.base.handlers.AuthenticatedHandler

IPython-specific extensions to authenticated handling

Mostly property shortcuts to IPython-specific settings.

allow_credentials

Whether to set Access-Control-Allow-Credentials

allow_origin

Normal Access-Control-Allow-Origin

allow_origin_pat

Regular expression version of allow_origin

get_json_body()

Return the body of the request as JSON data.

get_template(name)

Return the jinja template object for a given name

log

use the IPython log by default, falling back on tornado’s logger

set_default_headers()

Add CORS headers, if defined

write_error(status_code, **kwargs)

render custom error pages

class IPython.html.base.handlers.Template404(application, request, **kwargs)

Bases: IPython.html.base.handlers.IPythonHandler

Render our 404 template

class IPython.html.base.handlers.AuthenticatedFileHandler(application, request, **kwargs)

Bases: IPython.html.base.handlers.IPythonHandler, tornado.web.StaticFileHandler

static files should only be accessible when logged in

validate_absolute_path(root, absolute_path)

Validate and return the absolute path.

Requires tornado 3.1

Adding to tornado’s own handling, forbids the serving of hidden files.

class IPython.html.base.handlers.FileFindHandler(application, request, **kwargs)

Bases: tornado.web.StaticFileHandler

subclass of StaticFileHandler for serving files from a search path

classmethod get_absolute_path(roots, path)

locate a file to serve on our static file search path

validate_absolute_path(root, absolute_path)

check if the file should be served (raises 404, 403, etc.)

class IPython.html.base.handlers.ApiVersionHandler(application, request, **kwargs)

Bases: IPython.html.base.handlers.IPythonHandler

class IPython.html.base.handlers.TrailingSlashHandler(application, request, **kwargs)

Bases: tornado.web.RequestHandler

Simple redirect handler that strips trailing slashes

This should be the first, highest priority handler.

class IPython.html.base.handlers.FilesRedirectHandler(application, request, **kwargs)

Bases: IPython.html.base.handlers.IPythonHandler

Handler for redirecting relative URLs to the /files/ handler

1 Function

IPython.html.base.handlers.json_errors(method)

Decorate methods with this to return GitHub style JSON errors.

This should be used on any JSON API on any handler method that can raise HTTPErrors.

This will grab the latest HTTPError exception using sys.exc_info and then:

  1. Set the HTTP status code based on the HTTPError
  2. Create and return a JSON body with a message field describing the error in a human readable form.