Complete the code to add a related resource link in the HTTP header.
response.headers['[1]'] = '<https://api.example.com/users>; rel="users"'
The Link header is used to provide related resource links in REST APIs.
Complete the code to parse the 'Link' header and extract the URL with rel='next'.
next_url = None links = response.headers.get('Link', '').split(',') for link in links: if 'rel=[1]' in link: next_url = link.split(';')[0].strip('<> ') break
To get the next page URL, we look for rel="next" in the Link header.
Fix the error in the code that builds a Link header with multiple related resources.
link_header = ', '.join([f'<{url}>; rel=[1]' for url in urls]) response.headers['Link'] = link_header
When linking multiple related resources, the rel attribute should be "related" to indicate general related links.
Fill both blanks to create a dictionary comprehension that maps resource names to their URLs from a list of tuples.
related_links = [1]([2]: url for url, [2] in resources)
We use dict to create a dictionary, mapping each name to its URL.
Fill all three blanks to filter related links with rel='related' and extract their URLs.
related_urls = [link.split(';')[0].strip('<>') for link in response.headers.get('[1]', '').split(',') if '[2]' in link and link.split('rel=')[1].strip('"') == [3]]
The Link header contains related resource links. We filter links containing rel=related and check if the rel value equals "related".