!7
!include once #1028763 // helper for HttpFromFileSystem
set flag NoNanoHTTPD.
cmodule ServeDir > DynPrintLog {
!include #1029545 // API for Eleu
switchable File dir;
O html(virtual Request request) {
S uri = cast get(request, 'uri);
HttpFromFileSystem server = new(dir);
server.serveFile = f -> {
if (fileHasExtension(f, ".html"))
ret rewriteHTML(loadTextFile(f));
ret server.serveFile_base(f);
};
ret server.serve(uri);
}
S rewriteHTML(S html) {
LS tok = htmlTok(html);
// drop dummy chat bot CSS
listSet(tok, indexOf(tok, [[]]), "");
// drop dummy chat bot
int iJS = indexOf(tok, [[