Change URL pattern for retrieving audio feature data

Added 'api' as a prefix to make the URL consistent with the genre data
retrieval URL.
This commit is contained in:
Chris Shyi
2018-06-27 12:07:38 -04:00
parent 3af1ce852e
commit f8bf751920
3 changed files with 8 additions and 2 deletions

View File

@@ -50,7 +50,7 @@
// define the vertical scaling function // define the vertical scaling function
let vScale = d3.scaleLinear().range([height, 0]); 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) { .then(function(response) {
// categorize the data points // categorize the data points
for (let dataPoint of response.data_points) { for (let dataPoint of response.data_points) {

View File

@@ -14,6 +14,6 @@ urlpatterns = [
path('graphs/genre/<str:client_secret>', display_genre_graph, path('graphs/genre/<str:client_secret>', display_genre_graph,
name='display_genre_graph'), name='display_genre_graph'),
path('audio_features/<str:client_secret>', audio_features, name='audio_features'), 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'), get_audio_feature_data, name='get_audio_feature_data'),
] ]

View File

@@ -205,6 +205,12 @@ def display_genre_graph(request, client_secret):
return render(request, "spotifyvis/genre_graph.html", context) return render(request, "spotifyvis/genre_graph.html", context)
def audio_features(request, client_secret): 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) user = User.objects.get(user_secret=client_secret)
context = { context = {
'user_id': user.user_id, 'user_id': user.user_id,