input: from typing import Optional
  
  def read_url(url: str) -> Optional[str]:
      """ Reads the contents of a given URL and returns it as a string. 
          Returns None if the request fails.
          >>> read_url('http://example.com')
          '<!doctype html>\n<html>\n....' # Example output for illustration only.
          >>> read_url('http://nonexistenturl')
          None
      """
      import requests
      r = requests.get(url)
      if r.status_code == 200:
          return r.text
      else:
          return None
output:     import requests
      r = requests.get(url)
      if r.status_code == 200:
          return r.text
      else:
          return None