def create(): if request.method=="GET": if 'user' not in session: return redirect(url_for("login")) return render_template("create.html") else: if request.form.has_key("tablogin"): return redirect(url_for("login")) if request.form.has_key("tabhome"): return redirect(url_for("home")) if request.form.has_key("tabsignup"): return redirect(url_for("signup")) if request.form.has_key("tabcreate"): return redirect(url_for("create")) if request.form.has_key("tabprofile"): return redirect(url_for("myprofile")) if request.form.has_key("tabsurvey"): return redirect(url_for("survey")) if request.form.has_key("tabresults"): return redirect(url_for("results")) if request.form.has_key("submitcreate"): surveyname = str(request.form['surveyname']) questions = [] for i in range(1, 6): questions.append([str(request.form['q'+str(i)]), str(request.form['q'+str(i)+'type'])]) print surveyname, questions util.createSurvey(surveyname, questions) return redirect(url_for('create'))
def submitSurvey(): surveyname = request.args.get("surveyname", "") questions = request.args.get("questions", "") questions = questions.split(",") qs = [] for i in range(0, len(questions)): if i % 2 == 0: qs.append([questions[i], questions[i + 1]]) return json.dumps(util.createSurvey(surveyname, qs))
if 'user' not in session: return redirect(url_for("login")) return render_template("create.html") else: if request.form.has_key("tablogin"): return redirect(url_for("login")) if request.form.has_key("tabhome"): return redirect(url_for("home")) if request.form.has_key("tabsignup"): return redirect(url_for("signup")) if request.form.has_key("tabcreate"): return redirect(url_for("create")) if request.form.has_key("tabprofile"): return redirect(url_for("myprofile")) if request.form.has_key("tabsurvey"): return redirect(url_for("survey")) if request.form.has_key("tabresults"): return redirect(url_for("results")) if request.form.has_key("submitcreate"): surveyname = str(request.form['surveyname']) questions = [] for i in range(1, 6): questions.append([str(request.form['q'+str(i)]), str(request.form['q'+str(i)+'type'])]) print surveyname, questions util.createSurvey(surveyname, questions) return redirect(url_for('create')) if __name__ == "__main__": util.createSurvey('roommate', [['How much of a night owl are you?', 'number'],['On a scale of 1 to 5, how quiet do you want your room to be?', 'number'],['How much to you agree with the following statement: I will spend most of my free time in my room.', 'word'],['How much to you agree with the following statement: "I always have friends over.', 'word'],['How much do you agree with the following statement: I need my room to be clean and organized.', 'word']]) app.run(host='0.0.0.0', port=6565)
return redirect(url_for("results")) @app.route("/submitSurvey") def submitSurvey(): surveyname = request.args.get("surveyname", "") questions = request.args.get("questions", "") questions = questions.split(",") qs = [] for i in range(0, len(questions)): if i % 2 == 0: qs.append([questions[i], questions[i + 1]]) return json.dumps(util.createSurvey(surveyname, qs)) if __name__ == "__main__": util.createSurvey( "roommate", [ ["How much of a night owl are you?", "number"], ["On a scale of 1 to 5, how quiet do you want your room to be?", "number"], [ "How much to you agree with the following statement: I will spend most of my free time in my room.", "word", ], ['How much to you agree with the following statement: "I always have friends over.', "word"], ["How much do you agree with the following statement: I need my room to be clean and organized.", "word"], ], ) app.run(host="0.0.0.0", port=6565)