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

192
Views
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 answers
Answer question

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 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!