0

I have a webserver that does not have the PHP protocol. It only has HTML. (its a raspberry pi running webiopi) I do connect to this page via smartphone, but since there are many i do not 100% know to what raspberry i am connected because IP addresses change regularely. I need a way to display the HOST name of the pi (i mean the computer name) inside the page. Since html is static i can only think of Javascript, but Javascript is executed at client side so i have no idea how to get the host name of the raspberry.

Any ideas?

--- additional info ----

will make clones of this rasp, thats the reason why it cant be hardcoded into html.

user2452250
  • 737
  • 2
  • 11
  • 25

2 Answers2

1

Doesn't webiopi use Python? Why can't you use that to put the dynamic hostname into the HTML?

Go here for an idea of how to put your markup together: http://code.google.com/p/webiopi/wiki/CUSTOMIZE

Go here for an example on how to grab the host info using python: How can I use Python to get the system hostname?

Community
  • 1
  • 1
Matthew Blancarte
  • 8,151
  • 2
  • 23
  • 34
0

You only have one webserver. Put the host name inside the HTML.

If you have clones, you have a process that changes the host name. Add to the script that sets the host name a routine that will overwrite an short HTML file, which could in turn be loaded in via JavaScript or iframe into every page. JavaScript may be useful if this host name is likely to change after the page has loaded, as you could reload the host name regularly.

Paul Gregory
  • 1,723
  • 20
  • 25
  • that is not an option unfortunately as it has to be automatic... but thanks for trying – user2452250 Feb 04 '14 at 20:50
  • How often does your webserver's "computer name" change? How often do you stumble across a website on an old IP that is not obviously different to your own? – Paul Gregory Feb 04 '14 at 20:52
  • the name never changes, but i will have to make a few hundred of them for a project so i cannot change the HTML for every single one. But i COULD pass the host name to the page i am watching via POST, as prior to loading the page i know the host. but if i have 5 pages open i wont know what page is what pi wihtout having it written. – user2452250 Feb 04 '14 at 20:55
  • Right. "I have one webserver but I will make 100 clones" is information missing from the original post. – Paul Gregory Feb 04 '14 at 20:58
  • How do you intend to set different "computer names" for each clone? Can you not update a HTML file as part of that process? – Paul Gregory Feb 04 '14 at 21:00
  • the computername is changed automatically via ssh. – user2452250 Feb 04 '14 at 21:04
  • You could possibly write the HTML file using the same process that is changing the computer name. – amit_g Feb 04 '14 at 21:10
  • That's pretty much what I said. I admit my saying "can you not do x" doesn't travel well. – Paul Gregory Feb 04 '14 at 21:15