Advertisement
Guest User

Untitled

a guest
Nov 10th, 2020
1,341
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. from flask import Flask, redirect, url_for, render_template
  2. from flask_dance.contrib.spotify import make_spotify_blueprint, spotify
  3.  
  4.  
  5. app = Flask(__name__)
  6. app.secret_key = "supersekrit"
  7.  
  8. spotify_blueprint = make_spotify_blueprint(
  9. client_id="****", client_secret="****", scope=["user-follow-read"])
  10. app.register_blueprint(spotify_blueprint, url_prefix="/spotify_login")
  11.  
  12.  
  13. @app.route('/')
  14. def hello_world():
  15. data = spotify.get("v1/me/following?type=artist")
  16.  
  17. if data.ok:
  18. return data.json()
  19. else:
  20. return "Hello World Hope"
  21.  
  22.  
  23. @app.route('/spotify')
  24. def spotify_login():
  25.  
  26. if not spotify.authorized:
  27. return redirect(url_for("spotify.login"))
  28. data = spotify.get("v1/me/following?type=artist")
  29.  
  30. if data.ok:
  31. return data.json()
  32. else:
  33. return "Bad Data"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement