def handle_request(path):
    """
    Return the current status.

    """
    accept = bottle.request.get_header("accept", default="text/plain")

    bottle.response.status = 200

    try:
        if "text/html" in accept:
            ret = CURRENT_STATE.as_html(path=path)
            bottle.response.content_type = "text/html"

        elif "application/json" in accept:
            ret = CURRENT_STATE.as_json(path=path)
            bottle.response.content_type = "application/json"

        elif "text/" in accept or "*/*" in accept:
            ret = CURRENT_STATE.as_json(path=path, with_indent=True)
            bottle.response.content_type = "text/plain"

        else:
            bottle.response.status = 407
            ret = "Cannot render data in acceptable content type"
    except StateError:
        bottle.response.status = 404
        ret = "Requested state component not found"

    return ret
def handle_request ( path ) : accept = bottle . request . get_header ( "accept" , default = "text/plain" ) bottle . response . status = 200 try : if "text/html" in accept : ret = CURRENT_STATE . as_html ( path = path ) bottle . response . content_type = "text/html" elif "application/json" in accept : ret = CURRENT_STATE . as_json ( path = path ) bottle . response . content_type = "application/json" elif "text/" in accept or "*/*" in accept : ret = CURRENT_STATE . as_json ( path = path , with_indent = True ) bottle . response . content_type = "text/plain" else : bottle . response . status = 407 ret = "Cannot render data in acceptable content type" except StateError : bottle . response . status = 404 ret = "Requested state component not found" return ret
Return the current status.