Warning
This documentation is for an old version of IPython. You can find docs for newer versions here.
Module: html.base.handlers
¶
Base Tornado handlers for the notebook server.
9 Classes¶
-
class
IPython.html.base.handlers.
AuthenticatedHandler
(application, request, **kwargs)¶ Bases:
tornado.web.RequestHandler
A RequestHandler with an authenticated user.
-
content_security_policy
¶ The default Content-Security-Policy header
Can be overridden by defining Content-Security-Policy in settings[‘headers’]
-
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.
-
login_handler
¶ Return the login handler for this application, if any.
-
-
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
-
jinja_template_vars
¶ User-supplied values to supply to jinja templates.
-
log
¶ use the IPython log by default, falling back on tornado’s logger
-
set_default_headers
()¶ Add CORS headers, if defined
-
version_hash
¶ The version hash to use for cache hints for static files
-
write_error
(status_code, **kwargs)¶ render custom error pages
-
-
class
IPython.html.base.handlers.
APIHandler
(application, request, **kwargs)¶ Bases:
IPython.html.base.handlers.IPythonHandler
Base class for API handlers
-
check_origin
()¶ Check Origin for cross-site API requests.
Copied from WebSocket with changes:
- allow unspecified host/origin (e.g. scripts)
-
-
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:
IPython.html.base.handlers.IPythonHandler
,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.)
-
classmethod
-
class
IPython.html.base.handlers.
APIVersionHandler
(application, request, **kwargs)¶
-
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
-
static
redirect_to_files
(path)¶ make redirect logic a reusable static method
so it can be called from other handlers.
-
static
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:
- Set the HTTP status code based on the HTTPError
- Create and return a JSON body with a message field describing the error in a human readable form.