Skip to content
dreamcode
dreamcode
Back to map
Flask basics · Lesson 36 of 44
+15 XP on finish
PYTHON APPLIED

Building routes with Flask

Flask is a lightweight Python web framework. You define routes that map URL paths to Python functions. Each route function returns a response, often as JSON data that a frontend can consume.

How it reads
@app.route("/api/stars") maps the URL path to the function below it
jsonify(stars) converts a Python list into a JSON HTTP response
Flask(__name__) creates the application instance
Cloud tip: Flask is called a 'micro' framework because it gives you only the essentials. You add extensions (like Flask-SQLAlchemy) as you need them.
Check your understanding
Answer all 3 to complete this lesson · +15 XP
1. What does the @app.route decorator do in Flask?
2. What does jsonify() return?
3. Why is Flask called a 'micro' framework?