Serving static files in aWOT

To serve static files such as images, CSS files, and JavaScript files, use the awot-static script found in awot-scipts.

Use the following command to install awot-scripts:

$ npm install awot-scripts --save-dev 

Example configuration used in the front-end project:

{
  "scripts": {
    "awot-static": "awot-static"
  },
  "awot-static": {
   "sources": "./build",
    "indexFile": "index.html",
    "sketchDir": "./ArduinoProject",
    "exclude": [
      "*.map"
    ]
  }
}

Execute the script by running npm run awot-static.

This will generate a static gzipped payload file StaticFiles.h to the sketchDir directory. Include the file with #include "StaticFiles.h" and to mount the http handlers call app.use(staticFiles());.

See the tutorial for more details.