Exemplo n.º 1
0
def home():
    if request.method=='GET':
        stories = mongo2.getStories()
        return render_template("homepage.html", stories=stories)
    else:
        stories = mongo2.getStories()
        button = request.form['button']
        if button == 'New Story':
            title = request.form["title"]
            if title != "":
                mongo2.newStory(title)
                stories = mongo2.getStories()
            return render_template("homepage.html", stories=stories)
Exemplo n.º 2
0
import pymongo
from pymongo import Connection
import mongo2

mongo2.newStory("New Story")
mongo2.newStory("NEWER STORY")
mongo2.newStory("NEWEST STORY")
mongo2.addComment("New Story","NEW COMMENT")
mongo2.addComment("NEWEST STORY","WHAT")
print "\n"
print mongo2.getStories()
print "\n\n"
print mongo2.getComments("New Story")
print "\n"
print mongo2.getComments("NEWEST STORY")
mongo2.deleteAll()