def do_GET(self):
     self.log_message("PW2PYwebHandler do_GET")
     #debug("GET " + self.path)
     if self.path in ['', '/', '/index']:
         self.path = '/index.html'
     #for this specific application this entry point:
     if self.path == '/index.html':
         self.path = '/pw2py.html'
     #parse url
     purl = urlparse.urlparse(self.path)
     path = purl.path
     debug("PW2PYwebHandler.do_GET() parsed: " + path)
     if path == '/schedules':
         #retrieve list of schedules
         schedules = [os.path.splitext(os.path.basename(x))[0] for x in glob.glob(os.curdir + os.sep + 'schedules' + os.sep + '*.json')]
         #print schedules
         self.send_response(200)
         self.send_header('Content-type', 'application/json')
         self.end_headers()
         self.wfile.write(json.dumps(schedules))
         return
     #
     #only allow certain file types to be retrieved
     elif any(path.endswith(x) for x in ('.ws','.html','.js','.css','.png','.jpg','.gif', '.svg', '.ttf', '.woff', '.txt','.map','.json')):
         HTTPWebSocketsHandler.do_GET(self)
     else:
         self.send_error(404,'Plugwise-2-py-web Page not found')
Esempio n. 2
0
 def do_GET(self):
     self.log_message("PW2PYwebHandler do_GET")
     #debug("GET " + self.path)
     if self.path in ['', '/', '/index']:
         self.path = '/index.html'
     #for this specific application this entry point:
     if self.path == '/index.html':
         self.path = '/pw2py.html'
     #parse url
     purl = urlparse.urlparse(self.path)
     path = purl.path
     debug("PW2PYwebHandler.do_GET() parsed: " + path)
     if path == '/schedules':
         #retrieve list of schedules
         schedules = [os.path.splitext(os.path.basename(x))[0] for x in glob.glob(os.curdir + os.sep + 'schedules' + os.sep + '*.json')]
         #print schedules
         self.send_response(200)
         self.send_header('Content-type', 'application/json')
         self.end_headers()
         self.wfile.write(json.dumps(schedules))
         return
     #
     #only allow certain file types to be retrieved
     elif any(path.endswith(x) for x in ('.ws','.html','.js','.css','.png','.jpg','.gif', '.svg', '.ttf', '.woff', '.txt','.map','.json')):
         HTTPWebSocketsHandler.do_GET(self)
     else:
         self.send_error(404,'Plugwise-2-py-web Page not found')
 def end_headers(self):
     self.send_header("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
     HTTPWebSocketsHandler.end_headers(self)
Esempio n. 4
0
 def end_headers(self):
     self.send_header("Strict-Transport-Security", "max-age=63072000; includeSubDomains")
     HTTPWebSocketsHandler.end_headers(self)