Complete the code to define a route for the home page in Flask.
from flask import Flask app = Flask(__name__) @app.route('[1]') def home(): return "Welcome!"
The root URL / is the standard route for the home page in Flask.
Complete the code to define a route for a user profile page with a dynamic username.
@app.route('/user/[1]') def profile(username): return f"User: {username}"
Flask uses <type:variable> syntax for dynamic route parts. <string:username> captures a string named 'username'.
Fix the error in the route decorator to correctly capture an integer post ID.
@app.route('/post/[1]') def show_post(post_id): return f"Post {post_id}"
Flask requires <int:variable> to capture integers in routes. <integer:post_id> is invalid.
Fill both blanks to create a route for editing a post with an integer ID and a function named edit_post.
@app.route('/post/[1]/edit') def [2](post_id): return f"Edit post {post_id}"
update_post instead of edit_post.The route needs <int:post_id> to capture the post ID as an integer, and the function name should be edit_post to match the task.
Fill all three blanks to create a route for deleting a comment with integer IDs for post and comment, and a function named delete_comment.
@app.route('/post/[1]/comment/[2]/delete') def [3](post_id, comment_id): return f"Delete comment {comment_id} from post {post_id}"
remove_comment which is not the expected name.Use <int:post_id> and <int:comment_id> to capture integer IDs, and name the function delete_comment to match the route's purpose.