Back End - kristinedomingo/cs373-idb GitHub Wiki
Flask
Flask is a Python web framework. It's primary usage was to, of course, run
the application, and to create a route /
that sent the index.html
file.
It's most important usage was to create routes that the client-side framework, AngularJS,
would use. For example, idb.py
has an @app.route('/get_artists')
that defined a function, get_artist_data()
. This function
made a request to Spotify's Web API, parsed and amended the information, and returned the data in
a JSON format.
Then, on the client side, an AngularJS service getArtists
used $http.get('/get_artists')
to retrieve
the JSON information. Calling the API in this manner made certain things like sorting the model tables
very simple and easy.
Organization
The back end groups routes into two separate categories. For each route category (artist, album, and track) you request either a selection of unspecified or arbitrary artists, albums or tracks based on certain parameters or you can request specifically the artists, albums or tracks you are interested in.
Non-specific requests
Requests made in the format /{artists,albums,tracks}/{page_num}?psize={psize}&sort={col_attr}&order={asc_desc}
allow a user make a request for looking for specific artists, albums or tracks. Instead the user can request a list of items, sorted by some attribute in descending or ascending order.
Specific requests
Requests in the format /{artists,albums,tracks}?ids={spotify_ids}
allow a user to make a request for specific artists, albums or tracks by including a comma separated string of spotify ids.