diff options
m--------- | grextras | 0 | ||||
-rw-r--r-- | python/gras/stats/__init__.py | 19 |
2 files changed, 13 insertions, 6 deletions
diff --git a/grextras b/grextras -Subproject 7cbe569b5fad028570403f0d0001ef418c8bc28 +Subproject 51ae5c0b296d513efddbbcd0096e2d020443e64 diff --git a/python/gras/stats/__init__.py b/python/gras/stats/__init__.py index 596616d..ce570b0 100644 --- a/python/gras/stats/__init__.py +++ b/python/gras/stats/__init__.py @@ -21,19 +21,26 @@ class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): s.end_headers() s.wfile.write(get_stats_registry[0]()) return - s.send_response(200) - s.send_header("Content-type", "text/html") - s.end_headers() path = s.path if path.startswith('/'): path = path[1:] if not path: path = 'main.html' - s.wfile.write(open(os.path.join(__path__, path)).read()) + target = os.path.join(__path__, path) + if os.path.exists(target): + s.send_response(200) + s.send_header("Content-type", "text/html") + s.end_headers() + s.wfile.write(open(target).read()) + else: + s.send_response(404) + s.send_header("Content-type", "text/html") + s.end_headers() + s.wfile.write("<p>not found</p>") import select class http_server(object): - def __init__(self, args, get_stats_xml): - get_stats_registry[0] = get_stats_xml + def __init__(self, args, top_block): + get_stats_registry[0] = top_block.get_stats_xml server_class = BaseHTTPServer.HTTPServer self._httpd = server_class(args, MyHandler) |