物理浏览器无法访问virtualbox上的python webserver代码?

时间:2017-03-15 07:06:47

标签: python-2.7 webserver virtualbox

为什么我无法从物理PC浏览器访问此代码?    我在Virtualbox上构建此代码,请帮助我。见下图

import socket

HOST, PORT = '', 8888

listen_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
listen_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
listen_socket.bind((HOST, PORT))
listen_socket.listen(1)
print 'Serving HTTP on port %s ...' % PORT
while True:
    client_connection, client_address = listen_socket.accept()
    request = client_connection.recv(1024)
    print request

    http_response = """\
HTTP/1.1 200 OK

Hello, World!
"""
    client_connection.sendall(http_response)
    client_connection.close()

refuse to connect

0 个答案:

没有答案