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

Add the host option in cli to facilitate other nodes to access #42

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions rio_glui/scripts/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ def convert(self, value, param, ctx):
type=int,
help="mapbox-gl tileSize (default is the same as `tiles-dimensions`)",
)
@click.option("--host", type=str, default="127.0.0.1", help="Webserver host (default: 127.0.0.1)")
@click.option("--port", type=int, default=8080, help="Webserver port (default: 8080)")
@click.option("--playground", is_flag=True, help="Launch playground app")
@click.option(
Expand All @@ -127,6 +128,7 @@ def glui(
tiles_dimensions,
nodata,
gl_tile_size,
host,
port,
playground,
mapbox_token,
Expand All @@ -145,6 +147,7 @@ def glui(
gl_tiles_size=gl_tile_size,
gl_tiles_minzoom=raster.get_min_zoom(),
gl_tiles_maxzoom=raster.get_max_zoom(),
host=host,
port=port,
)

Expand Down
31 changes: 16 additions & 15 deletions rio_glui/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
from tornado.httpserver import HTTPServer
from tornado.concurrent import run_on_executor


logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -67,18 +66,20 @@ class TileServer(object):
"""

def __init__(
self,
raster,
scale=None,
colormap=None,
tiles_format="png",
gl_tiles_size=None,
gl_tiles_minzoom=0,
gl_tiles_maxzoom=22,
port=8080,
self,
raster,
scale=None,
colormap=None,
tiles_format="png",
gl_tiles_size=None,
gl_tiles_minzoom=0,
gl_tiles_maxzoom=22,
host="127.0.0.1",
port=8080,
):
"""Initialize Tornado app."""
self.raster = raster
self.host = host
self.port = port
self.server = None
self.tiles_format = tiles_format
Expand Down Expand Up @@ -114,17 +115,17 @@ def __init__(
def get_tiles_url(self):
"""Get tiles endpoint url."""
tileformat = "jpg" if self.tiles_format == "jpeg" else self.tiles_format
return "http://127.0.0.1:{}/tiles/{{z}}/{{x}}/{{y}}.{}".format(
self.port, tileformat
return "http://{}:{}/tiles/{{z}}/{{x}}/{{y}}.{}".format(
self.host, self.port, tileformat
)

def get_template_url(self):
"""Get simple app template url."""
return "http://127.0.0.1:{}/index.html".format(self.port)
return "http://{}:{}/index.html".format(self.host, self.port)

def get_playground_url(self):
"""Get playground app template url."""
return "http://127.0.0.1:{}/playground.html".format(self.port)
return "http://{}:{}/playground.html".format(self.host, self.port)

def get_bounds(self):
"""Get RasterTiles bounds."""
Expand Down Expand Up @@ -275,7 +276,7 @@ class Template(web.RequestHandler):
"""

def initialize(
self, tiles_url, tiles_bounds, gl_tiles_size, gl_tiles_minzoom, gl_tiles_maxzoom
self, tiles_url, tiles_bounds, gl_tiles_size, gl_tiles_minzoom, gl_tiles_maxzoom
):
"""Initialize template handler."""
self.tiles_url = tiles_url
Expand Down