Skip to content

Instantly share code, notes, and snippets.

@AlexFrazer
Created April 23, 2014 12:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AlexFrazer/11213786 to your computer and use it in GitHub Desktop.
Save AlexFrazer/11213786 to your computer and use it in GitHub Desktop.
{% extends "index.html" %}
{% block charts %}
{% for c in charts %}
<div id="{{ c['id']}}"></div>
{% endfor %}
<script type="text/javascript">
var charts = {{ charts }}
</script>
<script src="{{ url_for('static', filename='render_charts.js') }}"></script>
{% endblock %}
$(document).ready(function() {
$.each(charts, function(index, chart){
$('#'+chart['id']).highcharts(chart);
})
});
@app.route('/render/')
def render_charts():
try:
charts = [{'chart_id': c['id'], 'chart': get_json(c['id'])
for c in dict(request.args)]
return render_template('render.html', charts=charts)
except KeyError as e:
abort(400)
def get_json(c):
with open(os.path.join(app.root_path, app.config['JSON'], c['id'], '.json'),'r') as j:
return j
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment