def get_handler(callback_on_token):
class HTTPHandler(BaseHTTPRequestHandler):
def do_GET(self):
"""Respond to a GET request."""
logger.debug('Received GET request %s', self.path)
parts = parse_qs(urlparse(self.path).query)
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
self.write("<html><head><title>Spotify oAuth</title></head>")
self.write("<body><p>This is a token response from Spotify.</p>")
self.write('<p>%r</p>' % parts)
self.write("<p>You accessed path: %s</p>" % self.path)
self.write(
"<p>Check spoppy, if everything went well you're logged in "
"now!</p>"
)
self.write("</body></html>")
if parts:
logger.debug('Got parts %s, calling callback', parts)
callback_on_token(parts)
def write(self, line):
self.wfile.write(line.encode('utf-8'))
return HTTPHandler
评论列表
文章目录