How to get selected value from dropdown list in python flask

Give us your feedback on the cafe!

Maximum of 150 Characters.

Feedback
Rating for Cafe
Submit!

I tried to use rating = request.form.get("rating") in my python code to obtain the value of "rating" from the form, however I was unable to get the value in rating at all. How can I get the selected value from the HTML form in python code?

Unable to get value selected in python from a dropdown using Flask

Asked by Briar Whitney on 2021-12-10
Tags: selected using unable value
6 Answers

Flask Tutorial in Visual Studio Code

Flask is a lightweight Python framework for web applications that provides the basics for URL routing and page rendering.

Flask is called a "micro" framework because it doesn't directly provide features like form validation, database abstraction, authentication, and so on. Such features are instead provided by special Python packages called Flask extensions. The extensions integrate seamlessly with Flask so that they appear as if they were part of Flask itself. For example, Flask doesn't provide a page template engine, but installing Flask includes the Jinja templating engine by default. For convenience, we typically speak of these defaults as part of Flask.

In this Flask tutorial, you create a simple Flask app with three pages that use a common base template. Along the way, you experience a number of features of Visual Studio Code including using the terminal, the editor, the debugger, code snippets, and more.

The completed code project for this Flask tutorial can be found on GitHub: python-sample-vscode-flask-tutorial.

If you have any problems, feel free to file an issue for this tutorial in the VS Code documentation repository.