This is just some ideas from a novice coder that you probably already know but, I would still like to mention it here as others may not know about it. PHP include statements from .php files can parse html to the browser from a server side file so my idea is to put the very minimal code needed to control the core utilizing BDub’s Tiny Web Server and then use an iframe. So no HTML is needed in the IDE code. So basically you have the Core say to the browser, “Hi I am Sparky, now let me shine”
It all works very well and you can have multiple iframe statements to section off the browser page with different inclusions from different output from the core or from different sources on the web.
The only thing I need to do is to figure out how to move the Core Token and ID numbers to an external file and then include them back as a variable in to my index.html to make it more secure.
Is this scheme the best approach ? (I’m not sure)
Update;
@zach (I believe in another topic) let me know that I only need to secure the Token No.
And what I meant best approach, I was referring to using HTML/PHP outside the core to maximize core usable coding space.
spydrop, from reading the forum I think there a need for both solutions. What is needed is a solid example for each of these approaches. Much like tinker, these would provide a good foundation for new members.
A JSON library comes to mind. It’s a little redundant with the web API, but I could see a valid use for it on some sort of secure internal network where you may not want to expose anything via the web API. It may also give you access to more network-available variables and/or functions.
I had it displaying a test page, but I had some issues with it not closing the socket last I looked at it. I’ve just been busy but will get back on finishing it up asap. Thanks for hanging in there
@mstelt, He made the HTML code in the serveWebPage() function in @BDub’s post above. You can safely strip out the LquidCrystal and lcd stuff.
The actual HTML code printed in serveWebpage() looks like this to your browser:
<html><body>BDub's Server Uptime: 12345 seconds</body></html>
There are a few day-job web developers here in the forums that can help you with the HTML code. It may be better to start a separate thread for it, but we’d be happy to help!
You can use a lot of html and some php or java in the IDE but its trial by error. One thing to do is place a forward slash in before any " mark (quotation mark) or where possible use an ’ (appostirphy) in the html/java/php code.
You can also link external pages such as *.css / *.js / *.php
Let me know if you need example code to start from.
I got it all running wiht replacing the " for ’ and putting all the code in a single line. I can split it up but my Core is having some problems with the busyness in my WiFi(not the most pretty code I wrote but ow well xd) but I want to add the .html page to the project besides the .ino file.Is there a way to do this in the Builder because I couldn’t find it.
I'm not sure that it's possible to do something like that. The Core doesn't have a "disk" per se, so you couldn't simply ask it to load something like index.html from a disk or flash. It is possible that you could create .cpp (or should it be .h?) files that are page-specific to help you organize. Something like this might work:
I would make those HTML sections global static char arrays so that they can be entirely in flash rather than use up RAM for them assuming they never change.