Serving tiles locally/offline

Hi,

I'm trying to serve raster tiles locally from my computer using two approaches shared online but I'm unable to get the tiles to display in the Shiny app.

The tiles were generated using gdal2tiles.py (see link below for output files):

$ gdal2tiles.py -s EPSG:4326 -a 0,0,0 -z 1-10 -w none VNM_msk_alt.vrt

Approach No. 1 to serve tiles:
Using this reference: see following post (seems I don't have permission to post URLs here)

My code:

server <- function(input, output, session) {
  addResourcePath("mytiles", "/home/user/Desktop/srtm2/VNM_msk_alt") 

   addTiles(urlTemplate = "/mytiles/{z}_{x}_{y}.png", 
             group = "DEM (SRTM) Vietnam") %>%

Approach No. 2 to serve tiles:
Using this reference: see following post (seems I don't have permission to post URLs here)

My code:
setwd("/home/user/RDATA/projects/ta")

server <- function(input, output, session) {
deamon_id <- servr::httd(port = 8003, daemon = TRUE)

addTiles(urlTemplate = "http://localhost:8003/VNM_msk_alt/{z}_{x}_{y}.png",
      group = "DEM (SRTM) Vietnam") %>%  

I've also tried by setting up a local http server with: $ python2 -m SimpleHTTPServer 8003

I've zoomed in and out at different levels in the Shiny viewer.

Thanks for suggestions on how to get this to work.

[ tiles link: see following post (seems I don't have permission to post URLs in this message)]

First reference: https://stackoverflow.com/questions/43046753/r-leaflet-offline-tiles-within-shiny#43104232
Second reference: https://stackoverflow.com/questions/42771185/r-leaflet-offline-map-tiles-not-loading

tiles can be downloaded from https://drive.google.com/file/d/0B8M7YJeUlB6AY1huWkl5dmhZd2s/view?usp=sharing

Copy your folder with your tiles (VNM_msk_alt) inside a www folder under your working directory.

But when I try to visualize it with this code
leaflet() %>% addProviderTiles("CartoDB.Positron", group = "CartoDB.Positron") %>% addTiles(urlTemplate = "VNM_msk_alt/{z}/{x}/{y}.png", group = "DEM (SRTM) Vietnam")

After two or three zoom levels, i get to see something that looks like Vietnam, but sits west of Australia. Something is wrong with the projection.
Hope this helps.

Placing the tiled files in the www directory enables the image to be displayed.

However, I haven't worked out why gdal2tiles is giving the weird projection error. I've tried with two data sources in EPSG4326 but still the output is wrong with Vietnam incorrectly placed. Do you know of another free utility (for Linux) that enables tiles be created?

There is a plugin for QGIS, called QTiles...
Give it a try.

I fixed the projection issue of gdal2tiles.py outputs by adding the following into app.R:

addTiles(urlTemplate = "VNM_msk_alt_col/{z}/{x}/{y}.png",
options = tileOptions(noWrap = TRUE, continuousWorld = TRUE, tms = TRUE, opacity = 1, tileSize =256),
group = "DEM (SRTM) Vietnam") %>%