2. Make an http connection

Putting it all together

Let’s take what we learned and create a Python script called make-an-http-connection.py.

    #!/usr/bin/env python3
    import urllib.request

    api_url = input('ArchivesSpace API URL: ')
    req = urllib.request.Request(api_url)

    response = urllib.request.urlopen(req)
    print(response.read().decode('utf-8'))

  1. In IDLE click on the file name and create a new file
  2. Type in the above
  3. Save the file as make-an-http-connection.py