Added exception handling for do_GET and do_POST