Complete the code to define a HEAD method handler that returns headers without a body.
def handle_request(request): if request.method == '[1]': return get_headers_only() else: return get_full_response()
The HEAD method requests headers only, without the response body.
Complete the code to respond to an OPTIONS request with allowed methods.
def handle_request(request): if request.method == 'OPTIONS': return {'Allow': '[1]'} else: return process_request(request)
The OPTIONS method response includes all allowed methods, including OPTIONS itself.
Fix the error in the code to correctly handle HEAD requests by removing the response body.
def handle_head(request): response = get_full_response() if request.method == '[1]': response.body = None return response
HEAD requests require the body to be empty but headers to be present.
Fill both blanks to create a dictionary comprehension that maps HTTP methods to their descriptions for OPTIONS response.
methods_info = {method: '[1]' for method in ['GET', 'POST', 'HEAD', 'OPTIONS'] if method [2] 'OPTIONS'}This comprehension maps methods except OPTIONS to the string 'supported'.
Fill all three blanks to build a response dictionary for OPTIONS method with method names, descriptions, and a flag.
response = {
'[1]': [method for method in allowed_methods],
'[2]': {method: '[3]' for method in allowed_methods}
}The response includes a list of methods and a dictionary of descriptions labeled 'supported'.