예제 #1
0
 def do_GET(self):
     path = compat_urlparse.urlparse(self.path)
     paramDict = dict([(key, value[0]) for key, value in compat_urlparse.parse_qs(path.query).items()])
     action, _, path = path.path.strip('/').partition('/')
     if path:
         path = path.split('/')
         if action in self.actionDict:
             try:
                 builder = self.actionDict[action](path=path, handler=self, **paramDict)
                 builder.start()
                 try:
                     builder.build()
                 finally:
                     builder.close()
             except BuildError as e:
                 self.send_response(e.code)
                 msg = compat_str(e).encode('UTF-8')
                 self.send_header('Content-Type', 'text/plain; charset=UTF-8')
                 self.send_header('Content-Length', len(msg))
                 self.end_headers()
                 self.wfile.write(msg)
             except HTTPError as e:
                 self.send_response(e.code, str(e))
         else:
             self.send_response(500, 'Unknown build method "%s"' % action)
     else:
         self.send_response(500, 'Malformed URL')
 def do_GET(self):
     path = compat_urlparse.urlparse(self.path)
     paramDict = dict([
         (key, value[0])
         for key, value in compat_urlparse.parse_qs(path.query).items()
     ])
     action, _, path = path.path.strip('/').partition('/')
     if path:
         path = path.split('/')
         if action in self.actionDict:
             try:
                 builder = self.actionDict[action](path=path,
                                                   handler=self,
                                                   **paramDict)
                 builder.start()
                 try:
                     builder.build()
                 finally:
                     builder.close()
             except BuildError as e:
                 self.send_response(e.code)
                 msg = compat_str(e).encode('UTF-8')
                 self.send_header('Content-Type',
                                  'text/plain; charset=UTF-8')
                 self.send_header('Content-Length', len(msg))
                 self.end_headers()
                 self.wfile.write(msg)
             except HTTPError as e:
                 self.send_response(e.code, str(e))
         else:
             self.send_response(500, 'Unknown build method "%s"' % action)
     else:
         self.send_response(500, 'Malformed URL')
예제 #3
0
 def query_dict(url):
     return compat_parse_qs(compat_urlparse.urlparse(url).query)
예제 #4
0
 def query_dict(url):
     return compat_parse_qs(compat_urlparse.urlparse(url).query)