BaşlayınÜcretsiz Başlayın

Using request and response headers

Headers contain additional information about your API calls, including the desired or used response format. Using accept and content-type headers, client and server can negotiate what response format to use.

In this exercise, you'll use headers to inspect response formats after making a request and make a new request specifying the desired format via the accept header.

The requests package has been imported for your convenience.

Bu egzersiz

Introduction to APIs in Python

kursunun bir parçasıdır
Kursu Görüntüle

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

response = requests.get('http://localhost:3000/lyrics')

# Print the response content-type header
print(response.____)
Kodu Düzenle ve Çalıştır