An alternative is to treat those files as binary files and embed them in source code as hexadecimal values. I’ve done this for embedding animated GIF data inside an Arduino sketch, and there’s a handy command to do so: “
xxd -i index.html index.html.h” This uses
xxd, a hex dump command-line utility included in Ubuntu distributions by default. I still have to modify the output file, though:
- Add “const” keyword to make sure it goes into flash storage instead of RAM.
- Remove “unsigned” keyword to fit with signature for WebServer
- Add a 0x00 to the end of the hex dump to null-terminate the string. (Technically it means I should add 1 to the “length” value as well, but I’m not using that value.)
Code for this project is publicly available on GitHub