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

293
Views
Dropdown Selected output in python using Flask

I'm a beginner in Flask(python). I'm stuck on this problem for quite a long now. I need to show plots on webpage based on the plot type selected in a dropdown list. I am able to add the Dropdown list which shows on the webpage. But I'm stuck in applying conditions based on the selected item in a dropdown list.

HTML code for dropdown list:

    <select name="Selected_plot" method="GET" action="/visualize">
        <option value="{{Selected_plot[0]}}" selected>{{Selected_plot[0]}}</option>
        {% for plots in Selected_plot[1:] %}
        <option value="{{plots}}">{{plots}}</option>
        {% endfor %}
    </select>

Python Code:

@app.route('/')
def home():
    Selected_plot = ['Scatter plot', 'Line Plot','Box Plot']
    return render_template('homepage.html' ,Selected_plot =Selected_plot)




@app.route('/visualize')
def visualize():
    """
    if Selected_plot = 'Scatter plot':
        #Scatter plot code 
    elif  Selected_plot  = 'Line Plot':
        #Line plot code 
    else Selected_plot = 'Box plot' :
        #Box plot Code
    """    
    canvas =  figurecanvas(fig)
    img = io.BytesIO()
    plt.tight_layout() 
    fig.savefig(img)
    img.seek(0)
    return send_file(img,mimetype = 'img/png')

I would really appreciate it if anyone in the community try to help me.

Thanks in advance

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!