python web server error handling -
this python webserver code. doesn't work error message wish. so, please, help me right generate error message.
import sys import http.server http.server import( simplehttprequesthandler) srvr=http.server.httpserver hnd=simplehttprequesthandler protocol='http/1.0' try: if sys.argv[1:]: port=int(sys.argv[1]) else: port=8000 srvradrs=('localhost',port) hnd.protocol_version=protocol h=srvr(srvradrs,hnd) except ioerror: self.send_error(404,'file not found please check 1 time again , come in right flie name!!!!!!!!!: %s' %self.path) print("it's worked , welcome web server!") h.serve_forever()
you utilize "self" in self.send_error, you're not within method (member function) of class c.q. object.
python-3.x error-handling webserver
No comments:
Post a Comment