Skip to content

Instantly share code, notes, and snippets.

@AlexFrazer
Created April 9, 2014 17:28
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/10294683 to your computer and use it in GitHub Desktop.
Save AlexFrazer/10294683 to your computer and use it in GitHub Desktop.
$.getJSON('/get_some_json', function(json_data) {
$('#my_rendering_div') {
// render my content
}
});
@app.route('/')
def index():
return redirect(url_for('date_index'), date=datetime.now().strftime('%Y%m')
@app.route('/<date>')
def date_index(date=None):
return render_template('template.html')
@app.route('/get_some_json/<date>')
def get_some_json(date=None):
data = get_data
try:
...
except KeyError as e:
k = datetime.strptime(sorted(date.keys(), reverse=True)[0], '%Y%m')
log.warning(str(e))
flash('invalid date entered. Redirecting you to: ', k.strftime('%B, %Y')
return redirect(url_for('get_some_json', date=k.strftime('%Y%m')
<html>
<head>
<!-- links -->
</head>
<body>
<div> <!-- navbar --> </div>
<div class="container">
<div id="my_rendering_div">
<img src="loady.gif"/>
{% with messages = get_flashed_messages() %}
{% if messages %}
<ul class="flashes">
{% for message in messages %}
<li>{{ message }}</li>
{% endfor %}
</ul>
{% endif %}
{% endwith %}
</div>
</div>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment