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
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
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
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
Great, great GIF XD
Are you sure? yes | no