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
  • 777
  • 2
  • 11
  • 26
  • You'll find the solution here: http://stackoverflow.com/a/17336519/3272179 – Zealot Feb 04 '14 at 20:43
  • thanks, already found that.. but i do not need the host intended as the part of the url. what i need is the host intended as computer name in the network. – user2452250 Feb 04 '14 at 20:45
  • "since there are many" what? Raspberry Pi servers that you own, or that people who might be allocated your old IP own? – Paul Gregory Feb 04 '14 at 20:54
  • coz i dont know how to do that.. never worked with python before. but if you know how and post it as an answer i can mark it. – user2452250 Feb 04 '14 at 20:57
  • You could use python script and javascript to get the results. http://code.google.com/p/webiopi/wiki/Tutorial_Basis – amit_g Feb 04 '14 at 20:57
  • @MatthewBlancarte it worked like a charm! if you post it as answer i can mark it as answer! thank you soo much! could kiss you.. :D – user2452250 Feb 05 '14 at 18:08
  • @user2452250 Happy to help. Just submitted it as an answer. – Matthew Blancarte Feb 05 '14 at 21:47

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,251
  • 2
  • 25
  • 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,733
  • 19
  • 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