Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

301
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda