def get_time_page():
    """
    returns and html page with the current time in it
    """
    time = httpdate.httpdate_now()
    html = "<html>  <body>  <h1> %s </h1> </body> </html>" % time
    return html
def Error_response(URI, error_code=404):
    """
    returns an HTTP 404 Not Found Error response:
    
    URI is the name of the entity not found 
    """
    errors = {500: "Server Error",
              404: "Not Found",
              301: "Moved Permanently",
              302: "Moved Temporarily",
              303: "See Other"
              }
    
    resp = []
    resp.append('HTTP/1.1 %i %s'%(error_code, errors[error_code]))
    resp.append(httpdate.httpdate_now())
    resp.append('Content-Type: text/plain')
    
    msg = "%i Error:\n %s \n %s"%( error_code, URI, errors[error_code] )    

    resp.append('Content-Length: %i'%( len(msg) ) )
    resp.append('')
    resp.append(msg)

    return "\r\n".join(resp)
def OK_response(entity):
    """
    returns an HTTP response: header and entity in a string
    """
    resp = []
    resp.append('HTTP/1.1 200 OK')
    resp.append(httpdate.httpdate_now())
    resp.append( 'Content-Type: text/plain' )
    resp.append('Content-Length: %i'%len(entity))
    resp.append('')
    resp.append(entity)

    return "\r\n".join(resp)
def OK_response(entity):
    """
    returns an HTTP response: header and entity in a string
    """
    resp = []
    resp.append("HTTP/1.1 200 OK")
    resp.append(httpdate.httpdate_now())
    resp.append("Content-Type: text/html")
    resp.append("Content-Length: %i" % len(entity))
    resp.append("")
    resp.append(entity)

    return "\r\n".join(resp)
def OK_response(entity, extension="html"):
    """
    returns an HTTP response: header and entity in a string
    """
    resp = []
    resp.append("HTTP/1.1 200 OK")
    resp.append(httpdate.httpdate_now())
    type = mime_types.get(extension, "text/plain")
    resp.append("Content-Type: %s" % type)
    resp.append("Content-Length: %i" % len(entity))
    resp.append("")
    resp.append(entity)

    return "\r\n".join(resp)
def OK_response(entity, extension='html'):
    """
    returns an HTTP response: header and entity in a string
    """
    resp = []
    resp.append('HTTP/1.1 200 OK')
    resp.append(httpdate.httpdate_now())
    type = mime_types.get(extension, 'text/plain')
    resp.append( 'Content-Type: %s'%type )
    resp.append('Content-Length: %i'%len(entity))
    resp.append('')
    resp.append(entity)

    return "\r\n".join(resp)
def Error_response(URI):
    """
    returns an HTTP 404 Not Found Error response:
    
    URI is the name of the entity not found 
    """
    resp = []
    resp.append('HTTP/1.1 404 Not Found')
    resp.append(httpdate.httpdate_now())
    resp.append('Content-Type: text/plain')
    
    msg = "404 Error:\n %s \n not found"%( URI )    

    resp.append('Content-Length: %i'%( len(msg) ) )
    resp.append('')
    resp.append(msg)

    return "\r\n".join(resp)