Flask

Flask

Test your Flask knowledge with free quizzes on MyCodeSkills covering core concepts.


  1. What is Flask in Python?

    • A web framework
    • A database
    • A compiler
    • A testing tool
  2. Which command installs Flask?

    • pip install flask
    • install flask
    • flask install
    • setup flask
  3. Flask is based on which programming language?

    • JavaScript
    • Java
    • Python
    • C++
  4. What does @app.route('/') do?

    • Deletes route
    • Defines a URL route
    • Starts the server
    • Renders a template
  5. What is the default port Flask runs on?

    • 3000
    • 8000
    • 5000
    • 8080
  6. What is the purpose of Flask Blueprints?

    • Code Formatting
    • Project Packaging
    • Code Reusability
    • Response Caching
  7. How do you register a Blueprint in Flask?

    • app.use()
    • app.register()
    • app.add_url_rule()
    • app.register_blueprint()
  8. What does the application factory pattern help with?

    • Single-file projects
    • Static files
    • App scalability and testing
    • Blueprint routing
  9. Which function is typically used to create the app in a factory pattern?

    • init_app()
    • create_app()
    • start_app()
    • run_app()
  10. What is a Flask Middleware used for?

    • Add styles
    • Handle background jobs
    • Intercept requests/responses
    • Connect databases
  11. What is the purpose of the Flask Application Factory pattern?

    • Reduce routing
    • Lazy database init
    • Create apps dynamically
    • None
  12. In Flask, what is a Blueprint?

    • A database config
    • A template
    • A reusable module
    • A view class
  13. Which function is typically used to register a Blueprint?

    • add_blueprint()
    • init_blueprint()
    • register_blueprint()
    • use_blueprint()
  14. What is the use of before_request in Flask?

    • Redirect users
    • Run code before each request
    • Modify headers
    • Log error only
  15. How can you handle 404 errors globally in Flask?

    • Use abort(404)
    • Use @app.errorhandler(404)
    • Use redirect(404)
    • Define 404.html