def main():
    if request.method == 'GET':
        storyids = mongo.getStoryIDs()
        stories = [ {'storyid': x,'title': mongo.getTitleByID(x)} for x in storyids ]
        return render_template('storystuff.html',
                               stories = stories)
    else:
        title = request.form['title']
        assert title != ""
        mongo.addStory(title)
        return redirect(url_for('main'))
def home():
	Stories = mongo.returnAllTitles()
	if request.method == 'POST':
		title = request.form['title']	
		button = request.form['button']
		if button == 'Continue':
			title = request.form['story']
			lines = mongo.getLines(title)
			return redirect(url_for('story', title = title, lines = lines))
		if button == 'Create':
			mongo.addStory(title)
			Stories = mongo.returnAllTitles()
		        return render_template("home.html", Stories = Stories)
		if button == 'Remove Stories':
			mongo.removeAll()
			Stories = mongo.returnAllTitles()
			return render_template("home.html", Stories = Stories)
	else:
		return render_template('home.html', Stories = Stories)		
def home():
    if request.method == "GET":
        return render_template("home.html", stories=mongo.getStoryNames())
    else:
        button = request.form["button"]
        if button == "Create":
            newTitle = request.form["newTitle"]
            if newTitle == "":
                print 'empty string case'
                flash("Please enter a title if you want to create a story")
            elif newTitle != "":
                mongo.addStory(str(newTitle))
            return redirect(url_for("home"))
        elif button == "Go":
            session['storyToView'] = request.form["stories"]
            print request.form['stories']
            if session['storyToView'] == "":
                flash("No stories are available. Please create a story.")
                return redirect(url_for("home"))
            return redirect(url_for("view")) #'stories' = dropdown
        elif button == "Drop":
            mongo.dropStory(request.form["stories"])
            return redirect(url_for("home"))