0
0
Flaskframework~20 mins

Why Flask as a micro-framework - Challenge Your Understanding

Choose your learning style9 modes available
Challenge - 5 Problems
🎖️
Flask Micro-Framework Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
🧠 Conceptual
intermediate
2:00remaining
Why is Flask called a micro-framework?

Flask is often described as a micro-framework. What does this mean about Flask's design and features?

AFlask requires no coding and automatically generates full web applications.
BFlask is designed to handle only small websites and cannot scale to larger applications.
CFlask includes a built-in database and admin panel by default.
DFlask provides only the core tools for web development, letting developers add extensions as needed.
Attempts:
2 left
💡 Hint

Think about what 'micro' means in terms of included features versus flexibility.

component_behavior
intermediate
2:00remaining
How does Flask handle routing with minimal setup?

Consider this Flask code snippet:

from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return 'Welcome!'

What happens when you visit the root URL '/' in a browser?

Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return 'Welcome!'
AThe browser shows a 404 error because no HTML template is provided.
BThe browser shows the text 'Welcome!' because Flask routes '/' to the home function.
CThe browser shows a blank page because Flask needs a template file.
DThe browser crashes because Flask requires a database connection.
Attempts:
2 left
💡 Hint

Flask routes URLs to functions that return responses directly.

lifecycle
advanced
2:00remaining
What happens when Flask app runs with debug=True?

When you run a Flask app with app.run(debug=True), what is a key behavior Flask adds during development?

Flask
from flask import Flask
app = Flask(__name__)

@app.route('/')
def home():
    return 'Hello!'

if __name__ == '__main__':
    app.run(debug=True)
AFlask automatically reloads the server when code changes and shows detailed error messages.
BFlask disables all logging and runs silently.
CFlask runs the app only once and then stops.
DFlask requires a database connection to start.
Attempts:
2 left
💡 Hint

Think about how developers want quick feedback during coding.

📝 Syntax
advanced
2:00remaining
Identify the syntax error in this Flask route definition

Look at this Flask route code:

from flask import Flask
app = Flask(__name__)

@app.route('/hello')
def hello():
return 'Hi there!'

What is the syntax error here?

Flask
from flask import Flask
app = Flask(__name__)

@app.route('/hello')
def hello():
    return 'Hi there!'
AThe return statement is not indented inside the function.
BThe route decorator is missing parentheses.
CThe function name hello is invalid in Flask.
DFlask requires double quotes for route paths.
Attempts:
2 left
💡 Hint

Check Python indentation rules inside functions.

🔧 Debug
expert
3:00remaining
Why does this Flask route raise an error?

Consider this Flask app code:

from flask import Flask
app = Flask(__name__)

@app.route('/greet/')
def greet():
    return f'Hello, {name}!'

if __name__ == '__main__':
    app.run()

What error will occur when accessing a URL like '/greet/Alice' and why?

Flask
from flask import Flask
app = Flask(__name__)

@app.route('/greet/<name>')
def greet(name):
    return f'Hello, {name}!'

if __name__ == '__main__':
    app.run()
ARuntimeError because Flask routes cannot have dynamic parts.
BSyntaxError because f-strings cannot be used in Flask routes.
CTypeError because the greet function is missing the 'name' parameter.
DNo error; the app runs and greets correctly.
Attempts:
2 left
💡 Hint

Check the function parameters matching the route variables.