def do_GET(self): try: #print self.path, " / " , self.path[1:4] if self.path[1:4] == "api": #print self.path[4:] APIRequest(self, self.wfile, self.path[4:]) #print self.wfile.read() return if self.path.endswith(".psp"): fi = os.path.normpath(baseFolder + self.path) if os.path.isfile(fi): fiout = check_output(["python", fi]) self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write(fiout) return if self.path.endswith(".png"): try: pid = self.path[1:-4] #global processes global processes proc = processes[int(pid)] proc.plot("pics" + self.path) plotimg = open("pics" + self.path) self.send_response(200) self.send_header('Content-type', 'image/jpeg') self.end_headers() self.wfile.write(plotimg.read()) print self.path except Exception as exp: print repr(exp) return return except IOError: self.send_error(404, 'File Not Found: %s' % self.path) except KeyboardInterrupt: print "keyboard interrupt" Thread.interrupt_main() except Exception as exp: exc_type, exc_value, exc_traceback = sys.exc_info() print_exception(exc_type, exc_value, exc_traceback, limit=10, file=sys.stdout)
def do_GET(self): try: #print self.path, " / " , self.path[1:4] if self.path[1:4] == "api": #print self.path[4:] APIRequest(self,self.wfile,self.path[4:]) #print self.wfile.read() return if self.path.endswith(".psp"): fi = os.path.normpath(baseFolder+self.path) if os.path.isfile(fi): fiout = check_output(["python", fi]) self.send_response(200) self.send_header('Content-type', 'text/html') self.end_headers() self.wfile.write(fiout) return if self.path.endswith(".png"): try: pid = self.path[1:-4] #global processes global processes proc = processes[int(pid)] proc.plot("pics" + self.path) plotimg = open("pics"+self.path) self.send_response(200) self.send_header('Content-type', 'image/jpeg') self.end_headers() self.wfile.write(plotimg.read()) print self.path except Exception as exp: print repr(exp) return return except IOError: self.send_error(404,'File Not Found: %s' % self.path) except KeyboardInterrupt: print "keyboard interrupt" Thread.interrupt_main() except Exception as exp: exc_type, exc_value, exc_traceback = sys.exc_info() print_exception(exc_type, exc_value, exc_traceback, limit=10, file=sys.stdout)