def do_GET(self):
        """
        Accepts GET requests to http://localhost:6500/, and stores the query
        params in the global dict. If shutdown_on_request is true, stop the
        server after the first successful request.

        The http request may contain the following query params:
            - state : unique identifier, should match what we passed to reddit
            - code  : code that can be exchanged for a refresh token
            - error : if provided, the OAuth error that occurred
        """

        parsed_path = urlparse(self.path)
        if parsed_path.path != '/':
            self.send_error(404)

        qs = parse_qs(parsed_path.query)
        self.params['state'] = qs['state'][0] if 'state' in qs else None
        self.params['code'] = qs['code'][0] if 'code' in qs else None
        self.params['error'] = qs['error'][0] if 'error' in qs else None

        body = self.build_body()

        # send_response also sets the Server and Date headers
        self.send_response(200)
        self.send_header('Content-Type', 'text/html; charset=UTF-8')
        self.send_header('Content-Length', len(body))
        self.end_headers()

        self.wfile.write(body)

        if self.shutdown_on_request:
            # Shutdown the server after serving the request
            # http://stackoverflow.com/a/22533929
            thread = threading.Thread(target=self.server.shutdown)
            thread.daemon = True
            thread.start()
def do_GET ( self ) : parsed_path = urlparse ( self . path ) if parsed_path . path != '/' : self . send_error ( 404 ) qs = parse_qs ( parsed_path . query ) self . params [ 'state' ] = qs [ 'state' ] [ 0 ] if 'state' in qs else None self . params [ 'code' ] = qs [ 'code' ] [ 0 ] if 'code' in qs else None self . params [ 'error' ] = qs [ 'error' ] [ 0 ] if 'error' in qs else None body = self . build_body ( ) self . send_response ( 200 ) self . send_header ( 'Content-Type' , 'text/html; charset=UTF-8' ) self . send_header ( 'Content-Length' , len ( body ) ) self . end_headers ( ) self . wfile . write ( body ) if self . shutdown_on_request : thread = threading . Thread ( target = self . server . shutdown ) thread . daemon = True thread . start ( )
Accepts GET requests to http://localhost:6500/, and stores the query
        params in the global dict. If shutdown_on_request is true, stop the
        server after the first successful request.

        The http request may contain the following query params:
            - state : unique identifier, should match what we passed to reddit
            - code  : code that can be exchanged for a refresh token
            - error : if provided, the OAuth error that occurred