PythonTutorials.net
Toggle Menu
Home
Online Python Compiler
Tutorials
Django
Flask
Scikit-Learn
NumPy
NLTK
Pillow
Blog
All Posts
Flask API Design and Testing
Evaluate how well you can create,document,and test RESTful APIs using Flask.
1. Which decorator is used to define a route in a Flask application?
@app.route
@flask.route
@route.app
@router
2. Which HTTP methods can be explicitly specified in the 'methods' parameter of Flask's @app.route decorator? (Select all that apply)
GET
POST
PUT
PATCH
DELETE
3. In Flask, the 'request' object is automatically available in all view functions without needing to import it.
True
False
4. What is the name of the Flask function that converts a Python dictionary to a JSON response with the correct 'application/json' Content-Type header?
5. Which HTTP status code should a Flask view function return when the requested resource cannot be found?
200 OK
404 Not Found
500 Internal Server Error
400 Bad Request
6. Which of the following tools are commonly used for testing Flask APIs? (Select all that apply)
pytest
unittest
Postman
curl
Django
7. Flask's 'jsonify' function returns a Response object with the 'Content-Type' header automatically set to 'application/json'.
True
False
8. What is the default port number used by the Flask development server when running with 'flask run' (without specifying --port)?
9. What is the primary purpose of Flask Blueprints?
To organize application routes and views into modular components
To handle database migrations
To enforce authentication for API endpoints
To automatically generate API documentation
10. Which environment variables are part of Flask's core configuration for running an application? (Select all that apply)
FLASK_APP
FLASK_ENV
FLASK_DEBUG
FLASK_PORT
DATABASE_URL
Reset
Answered 0 of 0 — 0 correct