WebUI Link to HTML Map

Hello,

I recently started a new Vanilla Server, since Bukkit is essentially dead at the moment. With Bukkit, I used to use DynMap to create a map of my server. However, I obviously can’t do that with a Vanilla Server, so I chose to user Overviewer instead. I’ve been able to get the map to render without an issue, and verified the render is correct/complete by downloading the map via ftp. However, ultimately, I would like the map to be hosted using the same web server as the WebUI you have provided.

I have transferred the rendered map folder(mcmap) to the html folder at ./usr/games/minecraft/html and have tried to access the map via https:\xxx.xxx.xxx.xxx:8080\mcmap but I get the following error:

404 Not Found
The path ‘/mcmap’ was not found.

Traceback (most recent call last):
File “/usr/lib/python2.7/dist-packages/cherrypy/_cprequest.py”, line 656, in respond
response.body = self.handler()
File “/usr/lib/python2.7/dist-packages/cherrypy/lib/encoding.py”, line 188, in call
self.body = self.oldhandler(*args, **kwargs)
File “/usr/lib/python2.7/dist-packages/cherrypy/_cperror.py”, line 386, in call
raise self
NotFound: (404, “The path ‘/mcmap’ was not found.”)

I have also tried including a link in the webUI header once I login to the map’s index.html page, but upon clicking the map, I get the previous error as well.

Based upon this, I’m guessing that your WebServer CherryPy has an event handler that is directing all navigation? Is this a correct assumption to make? If thats the case, what would I need to change in the python files to be able to link to another static web page. Any help/suggestions would be greatly appreciated.

Thanks

2 Likes

This is absolutely correct. In fact, if you check out the git repo, you can see where it happens:

What you’re seeing here is a Python convention that filenames can be represented as functions (index.html as def index(self)). Having first-hand experience with learning Cherrypy, I can attest it is a confusing adventure, to put it mildly.

As a result, I would greatly recommend against using Cherrypy to host files, such as a page for your overviewer map to display, for the following reasons:

  1. cherrypy is confusing
  2. you’d have to edit the mineos source for this specific use case
  3. you’d kinda be like…forking the git.

This could be a fun challenge, but unless you’re really trying to learn python/cherrypy, it’s a very tedious one. It is much like if you wanted to extend an existing control panel like Plesk or cPanel without plugin-functionality. It is for this reason I’d recommend you use a normal webserver and host on a port users would expect: 80.

Recommended route:

Using apt-get, install Hiawatha webserver (or lighttp, but probably not apache). Hiawatha is, unquestionably my favorite webserver I’ve ever worked with for simplicity of setup. You’ll configure one file “/etc/hiawatha/hiawatha.conf” and you’ll create a virtual directory where your overviewer HTML lives and voila, you’re set!

Recap:

  1. install Hiawatha
  2. configure Hiawatha (or use the official docs, which are very nice).
  3. open port in iptables.
  4. ensure accessibility through your router.

Hi hexparrot,

I appreciate you getting back to me. I was actually thinking of installing my own webserver if I could not get CherryPy to do what I want. However, I like to keep my server as light as possible, since I have it running on a VM that is also hosted by my GF’s primary gaming machine.

Luckily, after some studying of your code in server.py and looking over some of the tutorials on CherryPy, I was able to pick up a general sense of how CherryPy worked. It helps that I have a Computer Science background and work QA for a software company, so I’m used to studying other peoples code. Unfortunately though, I haven’t touched web programming since the very early days of my degree, so it took some time to orient myself again.

I was able to host the map by editing the server.py code. Since I already had the html files/folder in the current mineos folder, it was just a matter of having CherryPy recognize it as a valid static content source along with your assets folders (assets, js, css, img).

So I altered the following:

root_conf = {                                                                                                                                                                                                  
        '/assets': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'assets')
            },                                                                                                                                                                                                     
        '/css': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'css')
            },                                                                                                                                                                                                     
        '/img': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'img')
            },                                                                                                                                                                                                     
        '/js': {
            'tools.staticdir.on': True,
            'tools.staticdir.dir': os.path.join(html_dir, 'js')
            },                                                                                                                                                                                                                                                                                                                                                                                                         
        }

To Be:

root_conf = {                                                                                                                                                                                                  
    '/assets': {
        'tools.staticdir.on': True,
        'tools.staticdir.dir': os.path.join(html_dir, 'assets')
        },                                                                                                                                                                                                     
    '/css': {
        'tools.staticdir.on': True,
        'tools.staticdir.dir': os.path.join(html_dir, 'css')
        },                                                                                                                                                                                                     
    '/img': {
        'tools.staticdir.on': True,
        'tools.staticdir.dir': os.path.join(html_dir, 'img')
        },                                                                                                                                                                                                     
    '/js': {
        'tools.staticdir.on': True,
        'tools.staticdir.dir': os.path.join(html_dir, 'js')
        },                                                                                                                                                                                                     
    '/mcmap': {
       'tools.staticdir.on': True,
       'tools.staticdir.dir': os.path.join(html_dir, './mcmap'),
       'tools.staticdir.index': 'index.html'
       },                                                                                                                                                                                                      
    }

Luckily, it ended up being a small change. So when/if I do a git pull and wipe out my changes, I should be able to recreate them quickly.

This allows me to go directly to the map’s index.html via https://xxx.xxx.xxx.xxx:8080/mcmap or through the link I created on the main Admin page Header.

The next step will be to create a cron job to render the map routinely. I haven’t gotten around to it yet, but did notice that there was nothing listed in my cron list at all. Which made me wonder, what are you using to your cron jobs on the server backups, if your not using the standard linux list?

2 Likes

Ah, well you’re quite right that this is a small change. Despite you clearly explaning you’re working on serving simple static content, I tend to think of (as is most of my inquiries) people wanting to do something much more substantial that warrants a webserver, unambiguously.

That said, I actually still do recommend webservers, as they just have it down when it comes to ease of configuration, balancing, and maintenance.

You should definitely be doing regular updates of the web-ui, so more importantly you’ll want to commit your changes to git.

You won’t actually be forking it, but you will be making your own modifications that exist only on your own git-tree. When you update, your changes will be overwritten, but that can be avoided by the following commands:

# cd /usr/games/minecraft
# git add server.py 
# git status -s
M  server.py
# git commit -m 'added mcmap to static hosting path'
[master xxxxxxx] added mcmap to static hosting path
 1 files changed, 5 insertions(+), 1 deletions(-)

Then, when updating using git fetch, get merge origin/master, your changes will be maintained.

Cron is a common Linux utility, but is not omnipresent. Since I made MineOS to try to be distro-agnostic, I couldn’t depend on crontabs for scheduling like I have in the past, but instead use Cherrypy for scheduling intervals.

That said, crontabs are still very valid to use, they’re just not set up automatically. That’s where mineos_console.py comes in, which is a command line interface to all the MineOS capabilities that can be called via cron at a schedule of your choosing.

Since you’re not actually trying to do anything from MineOS’ functionality, you can just create a cron to render your map using normal cron tutorials and also guides for overviewer. For an overview on crontabs, you can see my wiki page.

Just wanted to put in a quick plug that this thread has been SOO helpful. Have been trying to do this exact thing and I’m sure it will be much easier now. Thanks!

1 Like