On Tue, Jul 20, 2010 at 10:25 PM, Rahul R <rahul8...@gmail.com> wrote: > how to catch exceptions from the simpleHTTPServer . ( srry if this sounds > ridiculous ) > the below is a small code snippet for a basic webserver . every time > whenever there is a HTTP GET/POST request i can see the feedback in the > terminal . how do i catch those feedbacks ?
Those are standard error messages (sys.stderr), you can get it like this: -------------------------------------------- --- browser.py 2010-07-20 22:51:33.000000000 +0530 +++ browser-new.py 2010-07-20 22:55:20.000000000 +0530 @@ -18,4 +18,10 @@ sa = httpd.socket.getsockname() print "Serving HTTP on", sa[0], "port", sa[1], "..." -httpd.serve_forever() +import sys +out = open("browser.log", "w") +sys.stderr = out +try: + httpd.serve_forever() +except: + out.close() -------------------------------------------- I hope you can understand unified diff format: http://en.wikipedia.org/wiki/Diff Regards, Baiju M _______________________________________________ BangPypers mailing list BangPypers@python.org http://mail.python.org/mailman/listinfo/bangpypers