Пример #1
0
def nStory():
    if request.method == "GET":
        return render_template("new.html")
    else:
        username = session['n']
        button = request.form['button']
        title = request.form['sTitle']
        line = request.form['entry']
        #valid input check
        error = ""
        if len(title) == 0:
            error += "Nothing submitted for title.\n"
        if len(line) == 0:
            error += " Nothing submitted for content."
        if len(error) > 0:
            return render_template("new.html", error=error)
        #add default period at end of submission
        #line=punctCheck(line)
        if line[-1] != ".":
            if line[-1] != "?":
                if line[-1] != "!":
                    line += "."


#redirect to newly created story
        if button == "Submit":
            module.makePost(username, title, line)
            return redirect('/story/%s' % title)
        #redirect home
        if button == "Cancel":
            return redirect(url_for('home'))
        else:
            return render_template("new.html")
Пример #2
0
def nStory():
    if request.method=="GET":
        return render_template("new.html")
    else:
        username=session['n']
        button=request.form['button']
        title=request.form['sTitle']
        line=request.form['entry']
        #valid input check
        error=""
        if len(title) == 0:
            error+="Nothing submitted for title.\n"
        if len(line) == 0:
            error+=" Nothing submitted for content."
        if len(error) > 0:
            return render_template("new.html", error=error)
        #add default period at end of submission
        #line=punctCheck(line)
        if line[-1] != ".":
            if line[-1] !="?":
                if line[-1] !="!":
                    line+="."       
#redirect to newly created story
        if button=="Submit":
            module.makePost(username, title, line)
            return redirect('/story/%s' %title)
        #redirect home
        if button=="Cancel":
            return redirect(url_for('home'))
        else:
            return render_template("new.html")