Created
April 9, 2014 17:28
-
-
Save AlexFrazer/10294683 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
$.getJSON('/get_some_json', function(json_data) { | |
$('#my_rendering_div') { | |
// render my content | |
} | |
}); |
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
@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') |
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
<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