code: def __init__(
      self, addr=None, base_url=None, use_relative_links=False
  ):
      self.app = DispatcherApp(
          base_url=base_url, use_relative_links=use_relative_links
      )
      self.base_url = base_url
      self.use_relative_links = use_relative_links
      self._thread = None
  
      if addr is None:
          # Allocate port
          self.ip = "127.0.0.1"
          self.port = -1
          max_attempts = 10
          port = 7001
          for _ in range(max_attempts):
              if self._local_port_available(port, rais=False):
                  self.port = port
                  _log.info("Found open port: {0}".format(port))
                  break
              else:  # pragma: no cover
                  _log.info("Port already in use: {0}".format(port))
                  port = random.randint(7002, 7999)
  
          else:  # pragma: no cover
              msg = """Could not find open port.
                  Consider calling `interpret.set_show_addr(("127.0.0.1", 7001))` first.
                  """
              _log.error(msg)
              raise RuntimeError(msg)
      else:
          self.ip = addr[0]
          self.port = addr[1]
  
imports: from IPython import display
  import re
  import requests
  import threading
  import os
  from .None import _udash
  from gevent.pywsgi import WSGIServer
  from flask import Flask
  import socket
  import random
  from string import Template
  import logging
label_desc: Use image node_id 1 to create a new AppRunner object  with example: obj = AppRunner(addr, base_url, use_relative_links)