Exemple #1
0
def extra_word():
    global data, extra_word, col_name, theme_name

    if request.method == 'GET':
        col_name, theme_name, data, extra_word = getData0()

    form = ChoiceForm()
    form.choose.choices = data.items()

    if form.validate_on_submit():
        if data[form.choose.data] == extra_word:
            answer = 1
            message = 'Вы правильно определили лишнее слово.'
        else:
            answer = 0
            message = 'Вы ошиблись в выборе лишнего слова. Лишнее слово - ' + extra_word.encode(
                'utf-8')
        putData(col_name, theme_name, 0, answer)
        return redirect(url_for('.interpreted', message=message))

    message = request.args['message']
    return render_template('extra_word.html',
                           title='Research',
                           form=form,
                           message=message)
Exemple #2
0
def home():
    form = FoodForm()
    # receive data
    if form.is_submitted():
        # get food choices
        food_choices = backend_functions.get_recipes(form.food.data)
        # load next page
        choiceForm = ChoiceForm()
        # receive data
        if choiceForm.validate_on_submit():
            # get recipe
            food_string = choiceForm.choice.data.replace(" ", "_")
            result = backend_functions.print_food(food_string)
            ### tryna add youtube stuff
            food_name = choiceForm.choice.data
            url = backend_functions.build_search_url(food_name)
            answer = backend_functions.get_result(url)
            table = backend_functions.addlist(answer)
            backend_functions.printStuff(table)
            result.append("\nYouTube Vidoes\n")
            for name, link, thumbnail in table:
                line = name + ": " + link + "\."
                result.append(line)
            ###
            # load results
            return render_template(
                "results.html", result=result)  # maybe add a redirect to home?
        return render_template("choices.html",
                               choiceForm=choiceForm,
                               options=food_choices)
    return render_template("home.html", title="ZotYum", form=form)
def registration():
    form = ChoiceForm()
    if form.validate_on_submit():
        choice = form.choice.data
        if choice == "student":
            return redirect(url_for('register_student'))
        else:
            return redirect(url_for('register_tutor'))

    return render_template("registration.html",
                           pages=nav_bar_pages_list,
                           form=form)
Exemple #4
0
def extra_word():
    global data, extra_word, col_name, theme_name

    if request.method == 'GET':
        col_name, theme_name, data, extra_word = getData0()

    form = ChoiceForm()
    form.choose.choices = data.items()

    if form.validate_on_submit():
        if data[form.choose.data] == extra_word:
            answer = 1
            message = 'Вы правильно определили лишнее слово.'
        else:
            answer = 0
            message = 'Вы ошиблись в выборе лишнего слова. Лишнее слово - ' + extra_word.encode('utf-8')
        putData(col_name, theme_name, 0, answer)
        return redirect(url_for('.interpreted', message=message))

    message = request.args['message']
    return render_template('extra_word.html', title='Research', form=form, message=message)