Пример #1
0
def page():
    global currentStory
    global timex
    if request.method == "GET":
        return render_template("page.html", Title=currentStory, restOfLines=util.getLines(currentStory))
    else:
        if request.form.has_key("submit"):
            newLine = request.form["newLineBox"]
            util.addLine(newLine, currentStory)
            return redirect(url_for("page"))
        else:
            return redirect(url_for("home"))
Пример #2
0
def home():
    util.auth()
    global story
    global numberStories
    numberStories = 0
    for title in util.getAllStoryTitles():
        numberStories = numberStories + 1
    story = ""
    if request.method=="GET":
        return render_template("home.html", giveTitles = util.getAllStoryTitles(), giveNumber = numberStories)
    if request.method=="POST":
         button = request.form["button"]
         if button == "AddScramble":
             util.addStory(storyTitle)
             for line in storyScramble:
                 util.addLine(storyTitle, line)
         if button == "Ok":
             story = str(request.form["storySelection"])
             return render_template("home.html", titleStory = story, giveLines = util.getStoryLines(story), giveNumber = numberStories)
         if button == "Add":
             story = request.form["NewStory"]
             util.addStory(story)
             return render_template("home.html", giveTitles = util.getAllStoryTitles(), giveNumber = numberStories)
         if button == "DropStories":
             util.dropStories()
             return render_template("home.html", giveTitles = util.getAllStoryTitles(), giveNumber = numberStories)
         if button == "scramble":
            storyTitle = ""
            storyScramble = []

            for thing in util.getAllStoryTitles():
                storyTitle = storyTitle + " " + thing
            for thing in util.getAllStoryTitles():
                 storyScramble.append(util.getLine(thing, randrange(0,util.getNumberLines(thing))))
            return render_template("home.html", scrambledStory = storyScramble, scrambledStoryTitle = storyTitle)
                 
         if button:
             util.addLine(button,request.form["NextLine"])
             return render_template("home.html", giveTitles = util.getAllStoryTitles(), giveNumber = numberStories)