mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-27 10:02:01 +00:00
36 lines
934 B
Python
Executable File
36 lines
934 B
Python
Executable File
#!/usr/bin/env python
|
|
from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
|
|
from os import curdir, sep
|
|
|
|
PORT_NUMBER = 58000
|
|
|
|
class myHandler(BaseHTTPRequestHandler):
|
|
def do_GET(self):
|
|
if self.path == "/":
|
|
self.path = "/http_server.py"
|
|
|
|
try:
|
|
f = open(curdir + sep + self.path)
|
|
self.send_response(200)
|
|
self.send_header('Content-type', 'text/plain')
|
|
self.end_headers()
|
|
self.wfile.write(f.read())
|
|
f.close()
|
|
return
|
|
|
|
except IOError:
|
|
self.send_error(404,'File Not Found: %s' % self.path)
|
|
|
|
def do_POST(self):
|
|
self.do_GET()
|
|
return
|
|
|
|
try:
|
|
server = HTTPServer(('', PORT_NUMBER), myHandler)
|
|
print 'Started httpserver on port ' , PORT_NUMBER
|
|
server.serve_forever()
|
|
|
|
except KeyboardInterrupt:
|
|
print '^C received, shutting down the web server'
|
|
server.socket.close()
|