Browse Source

Change URL pattern for retrieving audio feature data

Added 'api' as a prefix to make the URL consistent with the genre data
retrieval URL.
master
Chris Shyi 6 years ago
parent
commit
f8bf751920
  1. 2
      spotifyvis/templates/spotifyvis/audio_features.html
  2. 2
      spotifyvis/urls.py
  3. 6
      spotifyvis/views.py

2
spotifyvis/templates/spotifyvis/audio_features.html

@ -50,7 +50,7 @@
// define the vertical scaling function
let vScale = d3.scaleLinear().range([height, 0]);
d3.json(`/audio_features/${audioFeature}/{{ user_secret }}`)
d3.json(`/api/audio_features/${audioFeature}/{{ user_secret }}`)
.then(function(response) {
// categorize the data points
for (let dataPoint of response.data_points) {

2
spotifyvis/urls.py

@ -14,6 +14,6 @@ urlpatterns = [
path('graphs/genre/<str:client_secret>', display_genre_graph,
name='display_genre_graph'),
path('audio_features/<str:client_secret>', audio_features, name='audio_features'),
path('audio_features/<str:audio_feature>/<str:client_secret>',
path('api/audio_features/<str:audio_feature>/<str:client_secret>',
get_audio_feature_data, name='get_audio_feature_data'),
]

6
spotifyvis/views.py

@ -205,6 +205,12 @@ def display_genre_graph(request, client_secret):
return render(request, "spotifyvis/genre_graph.html", context)
def audio_features(request, client_secret):
"""Renders the audio features page
:param request: the HTTP request
:param client_secret: user secret used for identification
:return: renders the audio features page
"""
user = User.objects.get(user_secret=client_secret)
context = {
'user_id': user.user_id,

Loading…
Cancel
Save