Last active
August 29, 2015 14:17
-
-
Save chriddyp/6962d2cdf8c2da4a9b71 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def files_list(request): | |
import requests | |
import json | |
from requests.auth import HTTPBasicAuth | |
from django.shortcuts import redirect, render | |
auth = HTTPBasicAuth('chris', '') | |
headers = {'Plotly-Client-Platform': 'api', 'Content-Type': 'application/json'} | |
r = requests.get('https://api.plot.ly/v2/files/chris:-1', headers=headers, auth=auth) | |
files = json.loads(r.content)['results'] | |
for f in files: | |
if f['filetype'] == 'plot': | |
f['url'] = 'https://plot.ly/~' + '/'.join(f['fid'].split(':')) | |
else: | |
files.remove(f) | |
return render(request, 'listview.html', {'items': files}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% block content %} | |
{% for i in items %} | |
<div> | |
{{i.filename}} | |
<a href="{{i.url}}"> | |
<img src = "{{i.url}}.png"> | |
</a> | |
</div> | |
{% endfor %} | |
{% endblock %} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For interactive graphs, use: