Last active
December 20, 2015 22:38
-
-
Save vvikramjhu/6206176 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
<!--trying to build the simplest of Json examples for pocoo. --> | |
<html> | |
<head></head> | |
<body> | |
<input tyep="text" id="test" name="test"/> | |
<a href=" " id="calculate">calculate</a> | |
<script type="text/javascript" src="/static/jquery.js"></script> | |
<script type="text/javascript" > | |
$(function(){ | |
$("a#calculate").bind('click', function(){ | |
$.getJSON('/get_total', { | |
test: $('input[name="test"]').val() | |
}, function(data){ | |
alert("hello") | |
}); | |
}); return false | |
}); | |
</script> | |
</body> | |
</html> | |
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
#views.py-------------- | |
@app.route('/get_total') | |
def get_total(): | |
test = request.args.get('test') | |
test = "2013-08-11" | |
totalPrice = 0 | |
cursor = g.db.cursor() | |
cursor.execute('select sum(price) from invoice where date= ? ',(test, )) | |
for row in cursor.fetchall(): | |
totalPrice = row[0] | |
return jsonify(totalPrice) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment