Created
July 12, 2014 03:58
-
-
Save shurru/6cbe5267e91284b713eb 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, render_template | |
from pymongo import MongoClient | |
#setting up the flask app | |
app=Flask(__name__) | |
#connecting to mongoDB | |
client=MongoClient('localhost', 27017) | |
db=client.emosis | |
posts= db.posts | |
@app.route('/') | |
def home(): | |
return render_template('home.html') | |
@app.route('/insert', methods=['POST']) | |
def insert(data): | |
if request.method == 'POST': | |
result = data | |
posts.insert(result) | |
return "it worked!\n" | |
if __name__=='__main__': | |
app.run() | |
if __name__ == '__main__': | |
app.run(debug=True) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment