Python Flask Flashcards
What is a major advantage of Python being a dynamically typed language?
It increases flexibility and reduces lengthy coding requirements.
What is the purpose of a virtual environment (venv) in Python?
To create isolated environments for Python projects, ensuring different projects have their own dependencies and settings.
What is Flask?
A micro web framework for Python.
How do you install Flask in a virtual environment?
“pip install Flask”
Which decorator is used to define a route in a Flask application?
@app.route
Q7: In the given Flask code snippet, what is the purpose of the jsonify function?
“@app.route(“/books”, methods=[“GET”])
def get_books():
return jsonify(books)
“
To convert Python objects into a JSON response.
How do you start a Flask application defined in hello.py?
flask –app hello run
Which HTTP method is used to create a new resource in a RESTful service with Flask?
POST
What HTTP status code is returned when a new resource is successfully created in a RESTful API?
201 Created
How do you update an existing resource in a RESTful API with Flask?
Use the PUT method.