Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adding the ability to set the host on the flask app for using a remot… #126

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

dhrod5
Copy link

@dhrod5 dhrod5 commented Jun 29, 2018

…e selenium server

My usecase was that I wanted to have testing done using docker compose and selenium/standalone-chrome. Since they run in different containers you need to bind the host to 0.0.0.0 or the selenium container cannot access the LiveServer.

These changes allow you to configure your app to change the host that the LiveServer starts on like this:

def create_app(self): app.config.update( LIVESERVER_PORT=8943, LIVESERVER_HOST='0.0.0.0' )

@@ -453,7 +454,7 @@ def get_server_url(self):
"""
Return the url of the test server
"""
return 'http://localhost:%s' % self._port_value.value
return 'http://{}:{}'.format(self._configured_host, self._port_value.value)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To pass python2.6 testing, line should be apparently something more like

return 'http://{hostname}:{port}'.format(
    hostname=self._configured_host,
    port=self._port_value.value,
)

@@ -477,7 +478,7 @@ def socket_bind_wrapper(self):
return ret

socketserver.TCPServer.server_bind = socket_bind_wrapper
app.run(port=port, use_reloader=False)
app.run(port=port, use_reloader=False, host=self._configured_host)

self._process = multiprocessing.Process(
target=worker, args=(self.app, self._configured_port)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably also add the parameters here:

self._process = multiprocessing.Process(
    target=worker, args=(self.app, self._configured_host, self._configured_port)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link

@nelsnelson nelsnelson left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -477,7 +478,7 @@ def socket_bind_wrapper(self):
return ret

socketserver.TCPServer.server_bind = socket_bind_wrapper
app.run(port=port, use_reloader=False)
app.run(port=port, use_reloader=False, host=self._configured_host)

self._process = multiprocessing.Process(
target=worker, args=(self.app, self._configured_port)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -477,7 +478,7 @@ def socket_bind_wrapper(self):
return ret

socketserver.TCPServer.server_bind = socket_bind_wrapper
app.run(port=port, use_reloader=False)
app.run(port=port, use_reloader=False, host=self._configured_host)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Parameterize the worker method so that this can be simply host=host.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants