docs: def main():
      """Host a file."""
  
      description = """Host a file on the LAN."""
  
      argParser = _argparse.ArgumentParser(description=description)
      argParser.add_argument('file',
                             help='File to host')
      argParser.add_argument('-p', '--port',
                             help='Port to use. (default: 80/8000)',
                             type=int, default=0)
  
      args = argParser.parse_args()
  
      absFilePath = _path.abspath(_path.expandvars(_path.expanduser(args.file)))
      if not _path.isfile(absFilePath):
          _sys.stdout.write(u"Couldn't find/access file: " + args.file + "\n")
          _sys.exit(-1)
  
      tryDefaultPorts = args.port == 0
  
      # Code from http.server in Python3
      handler = FileHTTPServerHandler
      handler.protocol_version = "HTTP/1.0"
      handler.absFilePath = absFilePath
  
      port = 80 if tryDefaultPorts else args.port
  
      try:
          server_address = ("", port)
          httpd = _B.HTTPServer(server_address, handler)
      except IOError as e:
          # If it is a permission denied error, and we had been ambitiously
          # trying port, 80, let's try port 8000 instead
          if e.errno == 13 and tryDefaultPorts:
              port = 8000
              server_address = ("", port)
              httpd = _B.HTTPServer(server_address, handler)
          else:
              raise
  
      sa = httpd.socket.getsockname()
      _sys.stderr.write("Serving file {} on {}:{} ...\n"
                          .format(absFilePath, sa[0], sa[1]))
  
      possibleIps = getValidIPs()
      if len(possibleIps) == 0:
          _sys.stderr.write(u'No IPs for localhost found. ' +
                            u'Are you connected to LAN?\n')
      else:
          _sys.stderr.write(u'Download the file by pointing the browser ' +
                            u'on the remote machine to:\n')
          portStr = '' if port == 80 else ':' + str(port)
          for ip in possibleIps:
              _sys.stderr.write(u'\t' + ip + portStr + '\n')
  
      _sys.stderr.write('Press Ctrl-C to stop hosting.\n')
  
      try:
          httpd.serve_forever()
      except KeyboardInterrupt:
          _sys.stderr.write("\nKeyboard interrupt received, exiting.\n")
          httpd.server_close()
          _sys.exit(0)