QuizFlask/run.py
def add_question():
    '''this will add a posted question to the database and redirect to the admin route again'''
    if request.form:
        #we got a form back now process by getting the items by their name
        question = request.form.get("question")
        answer = request.form.get("answer")
        sql = "INSERT INTO questions(question,answer) VALUES(?,?)"
        cursor = get_db().cursor()
        cursor.execute(sql,(question,answer))
        get_db().commit()
    return redirect(url_for("admin"))
this will add a posted question to the database and redirect to the admin route again
this will add a posted question to the database and redirect to the admin route again
this will add a posted question to the database and redirect to the admin route again
def add_question():
    if request.form:
        question = request.form.get("question")
        answer = request.form.get("answer")
        sql = "INSERT INTO questions(question,answer) VALUES(?,?)"
        cursor = get_db().cursor()
        cursor.execute(sql,(question,answer))
        get_db().commit()
    return redirect(url_for("admin"))
def add_question ( ) : if request . form : question = request . form . get ( "question" ) answer = request . form . get ( "answer" ) sql = "INSERT INTO questions(question,answer) VALUES(?,?)" cursor = get_db ( ) . cursor ( ) cursor . execute ( sql , ( question , answer ) ) get_db ( ) . commit ( ) return redirect ( url_for ( "admin" ) )
this will add a posted question to the database and redirect to the admin route again
this will add a posted question to the database and redirect to the admin route again
'''this will add a posted question to the database and redirect to the admin route again''' #we got a form back now process by getting the items by their name