Quantcast
Viewing all articles
Browse latest Browse all 14069

How to display variable JSON data from python in HTML

I've been working on a playlist manager for Spotify using their API. Right now I have a python script that gets the data from the API and returns a json file, but i would like to import the data into a html table in order to style it and make it interactive. Essentially I need to do this but in python.I tried using json2html, but that just returns the data in the python file and I want the data to go into an html file for styling. I know nothing about html encoding in python so there may be a much simpler solution for my case, but I couldn't find anything I could apply. Here is the return function in my python script

def get_playlists():    if 'access_token' not in session:        return redirect('/login')    if datetime.now().timestamp() > session['expires_at']:        return redirect('/refresh-token')    headers = {'Authorization': f"Bearer {session['access_token']}"    }    response = requests.get(f'{API_BASE_URL}/playlists', headers=headers)    return response.json()

returns encoded json data of response


Viewing all articles
Browse latest Browse all 14069

Trending Articles