from flask import Flask, render_template, request, redirect

app_lulu = Flask(__name__)


app_lulu.vars = {}


app_lulu.questions = {}
app_lulu.questions["How many eyes do you have?"] = ("1", "2", "3")
app_lulu.questions["Which fruit do you like best?"] = ("banana", "mango", "pineapple")
app_lulu.questions["Do you like cupcakes?"] = ("yes", "no", "maybe")


app_lulu.nquestions = len(app_lulu.questions)
# should be 3


@app_lulu.route("/index_lulu", methods=["GET", "POST"])
def index_lulu():
    nquestions = app_lulu.nquestions
    if request.method == "GET":
        return render_template("userinfo_lulu.html", num=nquestions)
    else:
        # request was a POST
        app_lulu.vars["name"] = request.form["name_lulu"]
        app_lulu.vars["age"] = request.form["age_lulu"]

        f = open("%s_%s.txt" % (app_lulu.vars["name"], app_lulu.vars["age"]), "w")
        f.write("Name: %s\n" % (app_lulu.vars["name"]))
        f.write("Age: %s\n\n" % (app_lulu.vars["age"]))
from flask import Flask, render_template, request, redirect

app = Flask(__name__)

app.vars = {}
app.questions = {}
app.questions["How many eyes do you have?"] = ("1", "2", "3")
app.questions["Which fruit do you like best?"] = ("banana", "mango", "pineapple")
app.questions["Do you like cupcakes?"] = ("yes", "no", "maybe")

app.nquestions = len(app.questions)


@app.route("/index_lulu", methods=["GET", "POST"])
def index_lulu():
    nquestions = app.nquestions
    time_of_reward = "4pm"
    if request.method == "GET":
        return render_template("userinfo_lulu.html", num=nquestions, time=time_of_reward)
    else:
        # request is a POST
        app.vars["name"] = request.form["name_lulu"]
        app.vars["age"] = request.form["age_lulu"]

        f = open("%s_%s.txt" % (app.vars["name"], app.vars["age"]), "w")
        f.write("Name: %s\n" % (app.vars["name"]))
        f.write("Age: %s\n" % (app.vars["age"]))
        f.close()

        return redirect("/main_lulu")