JB4lt98 / Song-Recs

https://song-recommendations.vercel.app
0 stars 0 forks source link

Create Authorization and Reccomendation Routes #6

Open Scriptize opened 1 month ago

Scriptize commented 1 month ago

Make routes to handle authorization flow and reccomendation requests :

Here is some example HTML and Python to give an idea of how this might work with authentication (actual code may be different)

from flask import Flask, request
from api_wrapper import APIWrapper

app = Flask(__name__)
api = APIWrapper()
payload = {clientID: "id", clientSECRET: "secret"}

@app.route('/authorize', methods=['POST'])
def authorize():
    auth_link = api.authorize(payload)
    return redirect(auth_link)

if __name__ == '__main__':
    app.run()

if __name__ == '__main__':
    app.run()
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Spotify Authorization</title>
</head>
<body>
    <h1>Click the button to authorize Spotify</h1>
    <form action="/authorize" method="post">
        <button type="submit">Authorize Spotify</button>
    </form>
</body>
</html>