Esempio n. 1
0
def index():

    form = AskQuestionForm() # may need to be q and a form
    if form.validate_on_submit():
        question = Question(
                body=form.question.data,
                title=form.question_title.data,
                author=current_user)
        db.session.add(question)
        db.session.commit()
        flash('Your question has been posted.')
        return redirect(url_for('index')) # keep refresh from resubmitting post req

    questions = Question.get_recent_questions(limit=100)

    answers = [
            {
                'author': {'username': '******'},
                'body': 'You chase tennis balls.'
            },
            {
                'author': {'username': '******'},
                'body': 'To chase.'
            }
    ]
    return render_template(
            'index.html',
            title='Home',
            questions=questions,
            form=form,
            answers=answers)