Skip to content

Instantly share code, notes, and snippets.

@shurru
Created July 12, 2014 03:58
Show Gist options
  • Save shurru/6cbe5267e91284b713eb to your computer and use it in GitHub Desktop.
Save shurru/6cbe5267e91284b713eb to your computer and use it in GitHub Desktop.
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