My personal dotfiles
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

spotify_oauth2_callback_server.py 811B

12345678910111213141516171819202122232425
  1. try:
  2. from http.server import BaseHTTPRequestHandler, HTTPServer
  3. from urllib.parse import urlparse, parse_qs
  4. except ImportError:
  5. from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer
  6. from urlparse import urlparse, parse_qs
  7. class RequestHandler(BaseHTTPRequestHandler):
  8. def log_message(self, format, *args):
  9. return
  10. def do_GET(self):
  11. print(parse_qs(urlparse(self.path).query)["code"][0])
  12. self.send_response(200)
  13. self.send_header('Content-type','text/html')
  14. self.end_headers()
  15. self.wfile.write("<h1>Success!</h1><p>You may close this window and go back to Emacs now. :-)</p>".encode("utf-8"))
  16. try:
  17. server = HTTPServer(('', 8591), RequestHandler)
  18. server.handle_request()
  19. except KeyboardInterrupt:
  20. server.socket.close()