Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

190
Visualizações
module 'werkzeug.wrappers.request' has no attribute 'form' Error for Flask project

The question here might be repeated, but I was not able to get a solution from any material available online. I am trying to get the value of the Selected Dropdown list as a string, So that later based on the selected item I can select the type of plot to be displayed. But I'm getting a 'form' error.

HTML code of the form:

        <form action="{{ url_for('visualize') }}" method="GET">
            Select one from the given options:

            <select name="plots">
                <option value="{{Selected_plot[0]}}" selected>{{Selected_plot[0]}}</option>
                {% for plots in Selected_plot[1:] %}
                <option value="{{plots}}">{{plots}}</option>
                {% endfor %}
            </select>
            <input type="submit" value="Submit" />
        </form>

python code :

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


@app.route('/visualize', methods=['POST', 'GET'] )
def visualize():
    """Renders the contact page."""
    if request.method == "GET":
        plot_selected = str(request.form['plots'])

    if plot_selected ==  'Scatter plot':
        #Scatter plot code 
    elif plot_selected ==  'Line Plot':
        # Line plot code
    else:
        # Box plot code 

Thanks to the Community in advance.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try

request.values.get("plots", <default_value>)

Note: <default_value> is whatever you wish to be the value if the program can't find the variable "plots". You can skip it if you're sure you'll always send the variable, plots.

The advantage of this format (request.values.get) is that it will work with both POST & GET (i.e. forms data passed through a POST/form-body or just query string)

about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda