-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generic support for embedding/serving static content #17
Comments
Mongoose, at least at v7.7, does have some support for this - see |
Looks like we don't need that filesystem support for TLS, mongoose has got this clever shortcut for files that start with I don't think if their filesystem support is really appropriate for serving general static assets - it reads the whole file at once, in to a buffer allocated with |
That is rubbish, I think the code in the OpenEVSE works reasonably well. Doing a bit of work on the script to make it a bit more flexible (for the v2 UI). It would also be nice to support any Arduino filesystem as well, but this needs the ability to override the normal file system calls and replace with the Arduino equipment. |
You could start with the most common file system used by ESP Arduino, which is LittleFS. fs::LittleFSFS sysFS;
server.serveStatic("/",sysFS,"/").setCacheControl(ONE_HOUR_CACHE_TIME);
server.on("/",HTTP_GET,[this](AsyncWebServerRequest *request){
AsyncWebServerResponse *response = request->beginResponse(
sysFS,
INDEX_PATH,
"text/html"
);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
});
serveStatic method looks like this in this library AsyncStaticWebHandler& AsyncWebServer::serveStatic(const char* uri, fs::FS& fs, const char* path, const char* cache_control){
AsyncStaticWebHandler* handler = new AsyncStaticWebHandler(uri, fs, path, cache_control);
addHandler(handler);
return *handler;
} |
anyone could serve static files with LittleFS? |
When you want to do OTA updates, it is convenient to merge the web UI files on to the firmware so you don't need a secondary process for updating them. |
What I want is to serve a htnl files in littlefs |
That is what the goal of #16 is |
Move the code from https://github.com/OpenEVSE/ESP32_WiFi_V3.x/ for embeding/serving static content embedded into the firmware.
Maybe also consider alternative methods, eg https://github.com/Aircoookie/WLED
The text was updated successfully, but these errors were encountered: