Browse Source
Merge branch 'in-progress' of https://github.com/Kevin-Mok/spotify-lib-vis into in-progress
master
Merge branch 'in-progress' of https://github.com/Kevin-Mok/spotify-lib-vis into in-progress
master
Chris Shyi
7 years ago
7 changed files with 100 additions and 10 deletions
-
11spotifyvis/static/spotifyvis/scripts/test_db.js
-
1spotifyvis/templates/spotifyvis/index.html
-
27spotifyvis/templates/spotifyvis/test_db.html
-
14spotifyvis/urls.py
-
36spotifyvis/utils.py
-
17spotifyvis/views.py
@ -0,0 +1,11 @@ |
|||
console.log("{{ user_id }}"); |
|||
artist_data = JSON.parse('{{ artist_data }}'); |
|||
artist_data.forEach(function(d) { |
|||
console.log(d.name, d.num_songs); |
|||
}); |
|||
|
|||
d3.json("{% url "get_artist_data" user_id %}", function(error, data) { |
|||
data.forEach(function(d) { |
|||
console.log(d.name, d.num_songs); |
|||
}); |
|||
}); |
@ -0,0 +1,27 @@ |
|||
<!DOCTYPE html> |
|||
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]--> |
|||
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]--> |
|||
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]--> |
|||
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]--> |
|||
<head> |
|||
<meta charset="utf-8"> |
|||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> |
|||
<title>Test DB Page</title> |
|||
<meta name="description" content=""> |
|||
<meta name="viewport" content="width=device-width, initial-scale=1"> |
|||
</head> |
|||
<body> |
|||
<!--[if lt IE 7]> |
|||
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p> |
|||
<![endif]--> |
|||
<ul> |
|||
{% for artist in artist_data %} |
|||
<li>{{ artist.name }} - {{ artist.num_songs }}</li> |
|||
{% endfor %} |
|||
</ul> |
|||
<pre> {% filter force_escape %} {% debug %} {% endfilter %} </pre> |
|||
<script src="http://d3js.org/d3.v3.js"></script> |
|||
{% load static %} |
|||
<script src="{% static "spotifyvis/scripts/test_db.js" %}"></script> |
|||
</body> |
|||
</html> |
@ -1,9 +1,13 @@ |
|||
from django.urls import path, include |
|||
from . import views |
|||
from django.conf.urls import url |
|||
|
|||
from .views import * |
|||
|
|||
urlpatterns = [ |
|||
path('', views.index, name='index'), |
|||
path('login', views.login, name='login'), |
|||
path('callback', views.callback, name='callback'), |
|||
path('user_data', views.user_data, name='user_data'), |
|||
path('', index, name='index'), |
|||
path('login', login, name='login'), |
|||
path('callback', callback, name='callback'), |
|||
path('user_data', user_data, name='user_data'), |
|||
path('test_db', test_db, name='test_db'), |
|||
path('user_artists/<str:user_id>', get_artist_data, name='get_artist_data'), |
|||
] |
Write
Preview
Loading…
Cancel
Save
Reference in new issue