Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

212
Views
Flask POST variable to be used in GET method

In my html template user enters multiple inputs to Select2 box, and I would like to populate rest of form inputs based on SQLite DB search for Select2 multi inputs in same GET response without reloading page. But I understand that I can not update server's GET response with new data. Is there a way to do it? On javascript I can not update HTML elements inner text because python has access to DB. As there are multiple inputs on select2 box instead of 1, I need to implement SQL query.

@app.route('/Enter', methods = ['POST','GET'])
def enter_case():
    if request.method == 'POST':
        MM_entered = request.get_json()  
        con = sqlite3.connect('DB.sql')
        curs = con.cursor()
        trace_masks = curs.executemany("""select Trace_Mask,MM,Description from TRACES where MM=?;""",MM_entered).fetchall()
        con.close()
        
#GET portion
    con = sqlite3.connect('DB.sql')
    curs = con.cursor()
    trace_masks = curs.execute("""select Trace_Mask,Framework_Trace_Mask,Description,MM from TRACES""").fetchall()
    con.close()

    trace,fr_trace,tr_Desc,MM = zip(*trace_masks)

    return render_template("Enter.html", data = trace,dataf = fr_trace, mm_list=MM) 

What I would like to add on GET:

    return render_template("Enter.html", data = trace_masks ). --> I want to add POST part, SQL response data here

JS

var mm_entered = new Array()

$('.mm_button').on('mouseover',e => {

    mm_entered = $('.js-example-basic-multiple').val()

    document.querySelector(".h8").innerHTML =
    document.querySelector(".Trace").style.display = "inline"

    const request = new XMLHttpRequest()
    request.open('POST',"Enter",true)
    request.setRequestHeader('Content-Type', 'application/json; charset=UTF-8')
    request.send(JSON.stringify(mm_entered))

})
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!