(self)
| 855 | logger.error("HTTP serving error", exc_info=exc_info) |
| 856 | |
| 857 | def get_url(self): |
| 858 | if not self._url: |
| 859 | if self._auto_wildcard: |
| 860 | display_host = socket.getfqdn() |
| 861 | # Confirm that the connection is open, otherwise change to `localhost` |
| 862 | try: |
| 863 | socket.create_connection( |
| 864 | (display_host, self.server_port), timeout=1 |
| 865 | ) |
| 866 | except socket.error as e: |
| 867 | display_host = "localhost" |
| 868 | |
| 869 | else: |
| 870 | host = self._host |
| 871 | display_host = ( |
| 872 | "[%s]" % host |
| 873 | if ":" in host and not host.startswith("[") |
| 874 | else host |
| 875 | ) |
| 876 | self._url = "http://%s:%d%s/" % ( |
| 877 | display_host, |
| 878 | self.server_port, |
| 879 | self._flags.path_prefix.rstrip("/"), |
| 880 | ) |
| 881 | return self._url |
| 882 | |
| 883 | def print_serving_message(self): |
| 884 | if self._flags.host is None and not self._flags.bind_all: |
no outgoing calls