from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler
import sys, pprint, time

class MyHTTPRequestHandler( BaseHTTPRequestHandler ):

    def do_GET( self ):
        self.send_response( 200, "OK" ); # First line.
        self.send_header( "Content-Type", "text/plain" );
        self.end_headers()

        year, month, day, hh, mm, ss, wd, y, z = time.gmtime()
        print >> self.wfile, "%04d-%02d-%02d %02d:%02d:%02d" % ( year,month,day, hh,mm,ss )


def run( port ):
    server_address = ('', port)

    httpd = HTTPServer( server_address, MyHTTPRequestHandler )

    print "Serving HTTP at http://localhost:%d/.  Use Ctrl-Break to end." % port
    httpd.serve_forever()


if __name__ == "__main__":
    _port = 8000
    if len(sys.argv)>1: _port = int(sys.argv[1])
    
    run( _port )

