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

159
Views
perform two different functions and one submit button using flask

I am trying to perform two different functions with single submit button, the below script shows the example of what I am trying to get. Thank you for helping me.
Expected solution --> when I click on submit button file has to upload along with map2 has redirect to mapRedirect url.

from flask import flask, render_template, flash, request, redirect,url_for
@app.route('/map2')
def map_2():
    return render_template('map2.html')
    

@app.route('/mapRedirect', methods = ['POST', 'GET'])
def onMap():
    if request.method == 'POST':
        name = request.form['nm']
        return redirect(f"map2")

@app.route('/proc')
def upload_file():
    ## file upload script
    return render_template('proc.html')

map2.html

<iframe name = "Ifrmp", id='mp', src="map2" >

proc.html

<form method="post" enctype="multipart/form-data" target="Ifrmp">
<input type="submit" id='btn' name="nm" value="submit>
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use JQuery to perform AJAX requests on those two functions.

<input type="submit" id='btn' form value="Click" onclick = 'button1();button2()'>

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<script>
    
    function button1() {
        $.get("/button1");
    }

    function button2() {
        $.post("/button2");
    }

</script>
about 4 years ago · Juan Pablo Isaza Report
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!