QuizFlaskAlchemy/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
        new_question = request.form.get("question")#get questions from form
        new_answer = request.form.get("answer")     #get answer from form
        new_question = Question(question=new_question,answer=new_answer)  #create a new question instance
        db.session.add(new_question)    #add it and commit change to db
        db.session.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:
        new_question = request.form.get("question")
        new_answer = request.form.get("answer")     
        new_question = Question(question=new_question,answer=new_answer)  
        db.session.add(new_question)    
        db.session.commit()
    return redirect(url_for("admin"))
def add_question ( ) : if request . form : new_question = request . form . get ( "question" ) new_answer = request . form . get ( "answer" ) new_question = Question ( question = new_question , answer = new_answer ) db . session . add ( new_question ) db . session . 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 #get questions from form #get answer from form #create a new question instance #add it and commit change to db