These are chat archives for SmingHub/Sming

12th
Jan 2017
laurentppol
@laurentppol
Jan 12 2017 08:23 UTC
@/all, could someone point me on (example / tutorial) how to do such thing:
  • I have HTML "template file", now I want to insert some data inside of it and send on request as WWW page
  • do have I to use BIG "string" variable and then substitute data?
  • is there another way?
  • template will be (I think) less than 10KB
laurentppol
@laurentppol
Jan 12 2017 08:42 UTC
will look at, THX Andrij :)
laurentppol
@laurentppol
Jan 12 2017 08:57 UTC
@petrynchyn maybe I don't understand this sample well but there is only "send file", and I need to read/modify/send the template. Could You help?
I don't know any thing about Ajax / Json :|
laurentppol
@laurentppol
Jan 12 2017 09:06 UTC
modify on SERVER side
Alexander V. Ribchansky
@avr39-ripe
Jan 12 2017 09:23 UTC
@laurentppol templating on server side is dead end.. much more easy/simple/powerful is json (for start, then binary data format) from server and client side processing of json. Modern JavaScript provides rather easy way of generating html page on the fly based on json data from server..
@laurentppol in my own application I switched to websockets + binary data over it + <template> tag in html + js to generate content on the fly..
laurentppol
@laurentppol
Jan 12 2017 09:25 UTC
ok, I understand, but this would require me to learn: JS, json, Ajax...
Alexander V. Ribchansky
@avr39-ripe
Jan 12 2017 09:26 UTC
@laurentppol yeah! indeed.. but.. this is now must know :)
laurentppol
@laurentppol
Jan 12 2017 09:26 UTC
and as (now) HTML code is 2kB size, it would me MUCH simpler to me to just read / replace / send...
just point me on how to do it
Alexander V. Ribchansky
@avr39-ripe
Jan 12 2017 09:28 UTC
@laurentppol I think same way some time ago.. my first app use sming's template engine.. but it is very basic templating ability..
@laurentppol peek at the link provided above :) this was my first try to use json from server side + ajax + js on client.. rather simple to understand..
laurentppol
@laurentppol
Jan 12 2017 09:30 UTC
I need only to substitute 4(8) strings based on server varialbles (for now), just point me on right example
Alexander V. Ribchansky
@avr39-ripe
Jan 12 2017 09:30 UTC
here is javascript + jquery (sorry for jquey :( ) https://github.com/SmingHub/Sming/blob/develop/samples/Basic_WebSkeletonApp/files/index.js on line 4 we request json data from server and on line 5 we assign html page with data we got from server
laurentppol
@laurentppol
Jan 12 2017 09:33 UTC
thx, will look at
you can take thes as it said as SKELETON for you app.. try to change peaces one by one to get your desired behavior :)
@laurentppol feel free to ask me further questions on this example, and not other too ;))
laurentppol
@laurentppol
Jan 12 2017 09:36 UTC
one more question: how to STOP webserver / deregister URL handlers?
Alexander V. Ribchansky
@avr39-ripe
Jan 12 2017 09:36 UTC
embed development is tricky thing.. you must master C/C++ + html/css/js :)) rather big stack :))
no need to do this.. no way by now.. why do you want to deregister url?
laurentppol
@laurentppol
Jan 12 2017 09:37 UTC
I already managed to send data I need over TCP, reading by Telnet or Perl script
Andriy Petrynchyn
@petrynchyn
Jan 12 2017 09:39 UTC
@avr39-ripe you do not plan to fix the NAT in SMING?
Alexander V. Ribchansky
@avr39-ripe
Jan 12 2017 09:40 UTC
@petrynchyn I plan, but do not know completely how... may be when external lwip will be in smingNONOS we can fix it by reduce mtu compile time..
there is some issue opende about lwip.. ping the author of it :)
laurentppol
@laurentppol
Jan 12 2017 09:50 UTC
I start WWW with config page (AP too) if there is no client connection, want to DISABLE WWW on connection (after config), then start ANOTHER WWW (different set of pages) on CLIENT connection.
client IP ~= server IP, but want to use same (80) "normal www" port
Alexander V. Ribchansky
@avr39-ripe
Jan 12 2017 10:01 UTC
@laurentppol for now it isn't possible to do so, but consider to change scenario a bit, there is no need of two page sets, just use one page for cinfiguration and others for actual useful work of you app.. again, see my example app.. there is AP config ability in it.. it can be enhanced, but for now it is sufficient