Пример #1
0
    def do_GET(self):
        """
        Handle a GET request and
        writes the ESP Rainmaker Welcome HTML page(response)
        back to HTTP Client

        :raises Exception: If there is any File Handling Issue

        :return: None on Success and Failure
        :rtype: None
        """
        log.debug('Loading the welcome page after successful login.')
        self.send_response(http_client.OK)
        self.send_header('Content-type', 'text/html')
        self.send_header('Access-Control-Allow-Origin', '*')
        self.end_headers()
        parts = urllib.parse.urlparse(self.path)
        query = _helpers.parse_unique_urlencoded(parts.query)
        self.server.query_params = query
        index_file = os.path.join(os.path.expanduser('.'), 'html/welcome.html')

        try:
            with open(index_file, 'rb') as home_page:
                self.wfile.write(home_page.read())
        except Exception as file_err:
            log.error(file_err)
            sys.exit(1)
Пример #2
0
 def do_GET(self):
     self.send_response(http_client.OK)
     self.send_header('Content-type', 'text/html')
     self.end_headers()
     parts = urllib.parse.urlparse(self.path)
     query = _helpers.parse_unique_urlencoded(parts.query)
     self.server.query_params = query
     self.wfile.write(
         b'<html><head><title>Authentication Status</title></head>')
     self.wfile.write(
         b'<body><p>The authentication flow has completed.</p>')
     self.wfile.write(b'</body></html>')
Пример #3
0
    def do_GET(self):
        """Handle a GET request.

        Parses the query parameters and prints a message
        if the flow has completed. Note that we can't detect
        if an error occurred.
        """
        self.send_response(http_client.OK)
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        parts = urllib.parse.urlparse(self.path)
        query = _helpers.parse_unique_urlencoded(parts.query)
        self.server.query_params = query
        self.wfile.write(
            b'<html><head><title>Authentication Status</title></head>')
        self.wfile.write(
            b'<body><p>The authentication flow has completed.</p>')
        self.wfile.write(b'</body></html>')
Пример #4
0
    def do_GET(self):
        """Handle a GET request.

        Parses the query parameters and prints a message
        if the flow has completed. Note that we can't detect
        if an error occurred.
        """
        self.send_response(http_client.OK)
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        parts = urllib.parse.urlparse(self.path)
        query = _helpers.parse_unique_urlencoded(parts.query)
        self.server.query_params = query
        self.wfile.write(
            b'<html><head><title>Authentication Status</title></head>')
        self.wfile.write(
            b'<body><p>The authentication flow has completed.</p>')
        self.wfile.write(b'</body></html>')
Пример #5
0
 def test_with_repeats(self):
     content = 'a=b&a=d'
     with self.assertRaises(ValueError):
         _helpers.parse_unique_urlencoded(content)
Пример #6
0
 def test_without_repeats(self):
     content = 'a=b&c=d'
     result = _helpers.parse_unique_urlencoded(content)
     self.assertEqual(result, {'a': 'b', 'c': 'd'})
Пример #7
0
 def test_with_repeats(self):
     content = 'a=b&a=d'
     with self.assertRaises(ValueError):
         _helpers.parse_unique_urlencoded(content)
Пример #8
0
 def test_without_repeats(self):
     content = 'a=b&c=d'
     result = _helpers.parse_unique_urlencoded(content)
     self.assertEqual(result, {'a': 'b', 'c': 'd'})