| 20 | |
| 21 | |
| 22 | class UpdateHttpServer(object): |
| 23 | def __init__(self, port, bind, catalog_dir): |
| 24 | def handler(*args): |
| 25 | UpdateHTTPRequestHandler(catalog_dir, *args) |
| 26 | httpd = BaseHTTPServer.HTTPServer((bind, port), handler) |
| 27 | sa = httpd.socket.getsockname() |
| 28 | logger.info('http server starting {0}:{1} {2}'.format(sa[0], sa[1], catalog_dir)) |
| 29 | try: |
| 30 | httpd.serve_forever() |
| 31 | except KeyboardInterrupt: |
| 32 | logger.info('Shutting down...') |
| 33 | httpd.socket.close() |
| 34 | |
| 35 | |
| 36 | class UpdateHTTPRequestHandler(BaseHTTPServer.BaseHTTPRequestHandler): |