ice.py
def cube():
    """Return an Ice application with a default home page.

    Create :class:`Ice` object, add a route to return the default page
    when a client requests the server root, i.e. /, using HTTP GET
    method, add an error handler to return HTTP error pages when an
    error occurs and return this object. The returned object can be used
    as a WSGI application.

    Returns:
      Ice: WSGI application.
    """
    app = Ice()

    @app.get('/')
    def default_home_page():
        """Return a default home page."""
        return simple_html('It works!',
                           '<h1>It works!</h1>\n'
                           '<p>This is the default ice web page.</p>')

    @app.error()
    def generic_error_page():
        """Return a simple and generic error page."""
        return simple_html(app.response.status_line,
                           '<h1>{title}</h1>\n'
                           '<p>{description}</p>\n'
                           '<hr>\n'
                           '<address>Ice/{version}</address>'.format(
                           title=app.response.status_line,
                           description=app.response.status_detail,
                           version=__version__))

    def simple_html(title, body):
        """Return a simple HTML page."""
        return (
            '<!DOCTYPE html>\n'
            '<html>\n<head><title>{title}</title></head>\n'
            '<body>\n{body}\n</body>\n</html>\n'
        ).format(title=title, body=body)

    return app
def cube():
    """Return an Ice application with a default home page.

    Create :class:`Ice` object, add a route to return the default page
    when a client requests the server root, i.e. /, using HTTP GET
    method, add an error handler to return HTTP error pages when an
    error occurs and return this object. The returned object can be used
    as a WSGI application.

    Returns:
      Ice: WSGI application.
    """
    app = Ice()

    @app.get('/')
    def default_home_page():
        """Return a default home page."""
        return simple_html('It works!',
                           '<h1>It works!</h1>\n'
                           '<p>This is the default ice web page.</p>')

    @app.error()
    def generic_error_page():
        """Return a simple and generic error page."""
        return simple_html(app.response.status_line,
                           '<h1>{title}</h1>\n'
                           '<p>{description}</p>\n'
                           '<hr>\n'
                           '<address>Ice/{version}</address>'.format(
                           title=app.response.status_line,
                           description=app.response.status_detail,
                           version=__version__))

    def simple_html(title, body):
        """Return a simple HTML page."""
        return (
            '<!DOCTYPE html>\n'
            '<html>\n<head><title>{title}</title></head>\n'
            '<body>\n{body}\n</body>\n</html>\n'
        ).format(title=title, body=body)

    return app
Return an Ice application with a default home page.

    Create :class:`Ice` object, add a route to return the default page
    when a client requests the server root, i.e. /, using HTTP GET
    method, add an error handler to return HTTP error pages when an
    error occurs and return this object. The returned object can be used
    as a WSGI application.

    Returns:
      Ice: WSGI application.