Close

Looks Like HTML's Back on the Menu

A project log for VoiceBox

Adding a Flask web interface (and other stuff) to the Google AIY Voice Kit.

tmTM 08/10/2018 at 23:213 Comments

I've been experimenting with ways to cross-link menus between flask applications running on different ports on the same server. None of the obvious ways to link to, say, the piHole menu on port :9012 from the Blinkter root page on port :9013 work. The best solution I could find via Google was a suggestion by Craig McQueen on StackExchange. When the link is clicked (onclick), a little embedded javascript is run to add the port number to the link. I've modified Craig's approach slightly to run the same script on right-click (oncontextmenu). This is to allow <right-click>, <open in new tab>, or <copy link location>.

<h5>
<a href="/" onclick="javascript:event.target.port=9010" oncontextmenu="javascript:event.target.port=9010">SysInfo</a>
  •  
<a href="/" onclick="javascript:event.target.port=9011" oncontextmenu="javascript:event.target.port=9011">VoiceBox</a>
  •  
<a href="/" onclick="javascript:event.target.port=9012" oncontextmenu="javascript:event.target.port=9012">piHole</a>
  •  
<a href="/" onclick="javascript:event.target.port=9013" oncontextmenu="javascript:event.target.port=9013">Blinkter</a>
</h5>

And the end result looks like this:

I'm going to add this menu bar to the bottom of the root pages of each of the server programs. Hacky, but good enough for my needs.

Discussions

TM wrote 08/13/2018 at 00:22 point

Stuart, thank you, that looks really clean. Maybe nginx will be "the one". I've never felt remotely in control with Apache or httpd.

  Are you sure? yes | no

TM wrote 08/11/2018 at 13:48 point

Stuart, the nginx solution at StackExchange looks very simple (src="http://$http_host:9012/"), but I don't want to open a whole can of worms for one environment variable. Maybe if I run the Pi full time I'll migrate stuff I currently have running under httpd on a separate server.

  Are you sure? yes | no

Morning.Star wrote 08/11/2018 at 11:44 point

Great, great GIF XD

  Are you sure? yes | no