Created
September 29, 2013 08:45
-
-
Save theycallmeswift/6750562 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from flask import Flask, request | |
app = Flask(__name__, static_folder='static', static_url_path='') | |
@app.route('/data', methods=['GET', 'POST']) | |
def post_data(): | |
data = request.data # but data will be empty unless the request has the proper content-type header... | |
if not data: | |
data = request.form.keys()[0] | |
# mongo.db.test1_collection.insert({ city: data }) | |
print data | |
return 'OK' | |
if __name__ == '__main__': | |
app.run(debug=True) |
This file contains hidden or 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><title>Foo</title></head> | |
<body> | |
<h1 id="foo">New York</h1> | |
<script src="http://codeorigin.jquery.com/jquery-2.0.3.min.js"></script> | |
<script> | |
$(document).ready(function() { | |
$.post("/data", $("#foo").html(), function(data) { console.log(data) }) | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment