Complete the code to define a route that accepts a dynamic username parameter.
from flask import Flask app = Flask(__name__) @app.route('/user/[1]') def show_user(username): return f"User: {username}"
In Flask, dynamic route parameters are enclosed in <> brackets.
Complete the code to convert the dynamic parameter to an integer in the route.
@app.route('/post/[1]') def show_post(post_id): return f"Post ID: {post_id}"
Use <int:parameter> to convert the route parameter to an integer.
Fix the error in the route decorator to correctly capture a float parameter named price.
@app.route('/price/[1]') def show_price(price): return f"Price: {price}"
Use <float:price> to capture a floating-point number in the route.
Fill both blanks to create a route that accepts a string category and an integer item_id.
@app.route('/shop/[1]/[2]') def show_item(category, item_id): return f"Category: {category}, Item ID: {item_id}"
Use <string:category> and <int:item_id> to specify types for both parameters.
Fill all three blanks to define a route with a string username, an integer year, and a float rating.
@app.route('/profile/[1]/[2]/[3]') def profile(username, year, rating): return f"User: {username}, Year: {year}, Rating: {rating}"
Use <string:username>, <int:year>, and <float:rating> to define the route parameters with types.