本文整理汇总了Python中django.core.servers.basehttp.WSGIServer.server_name方法的典型用法代码示例。如果您正苦于以下问题:Python WSGIServer.server_name方法的具体用法?Python WSGIServer.server_name怎么用?Python WSGIServer.server_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django.core.servers.basehttp.WSGIServer
的用法示例。
在下文中一共展示了WSGIServer.server_name方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: run_wsgi_server
# 需要导入模块: from django.core.servers.basehttp import WSGIServer [as 别名]
# 或者: from django.core.servers.basehttp.WSGIServer import server_name [as 别名]
def run_wsgi_server(self, addr, port, handler):
""" replaces ``django.core.servers.basehttp.run`` """
global PERSISTENT_SOCK
kwargs = dict(bind_and_activate=False)
if self.has_ipv6_support:
kwargs['ipv6'] = self.use_ipv6
httpd = WSGIServer((addr, port), WSGIRequestHandler, **kwargs)
# patch the socket
httpd.socket = PERSISTENT_SOCK
try:
httpd.server_bind()
except WSGIServerException, e:
if 'Errno 22' in str(e):
# may have been bound, just emulate some stuff done in server_bind (like setting up environ)
httpd.server_name = socket.getfqdn(addr)
httpd.server_port = port
httpd.setup_environ()
else:
raise