// deleteFile("/hello.txt"); | // deleteFile("/hello.txt"); | ||||
// writeFile("/hello.txt", "Hello "); | // writeFile("/hello.txt", "Hello "); | ||||
// appendFile("/hello.txt", "World!\n\r"); | // appendFile("/hello.txt", "World!\n\r"); | ||||
// readFile("/hello.txt"); | |||||
// printFile("/hello.txt"); | |||||
// listDir("/"); | // listDir("/"); | ||||
FSInfo fsinfo; | FSInfo fsinfo; | ||||
Serial.println(); | Serial.println(); | ||||
} | } | ||||
void readFile(const char * path) { | |||||
File open(const char * path) { | |||||
return LittleFS.open(path, "r"); | |||||
} | |||||
void printFile(const char * path) { | |||||
Serial.printf("Reading file: %s\n\r", path); | Serial.printf("Reading file: %s\n\r", path); | ||||
File file = LittleFS.open(path, "r"); | File file = LittleFS.open(path, "r"); |
bool mount_fs(); | bool mount_fs(); | ||||
bool format_fs(); | bool format_fs(); | ||||
File open(const char * path); | |||||
void ls(const char * dirname); | void ls(const char * dirname); | ||||
void readFile(const char * path); | |||||
void printFile(const char * path); | |||||
void writeFile(const char * path, const char * message); | void writeFile(const char * path, const char * message); | ||||
void appendFile(const char * path, const char * message); | void appendFile(const char * path, const char * message); | ||||
void renameFile(const char * path1, const char * path2); | void renameFile(const char * path1, const char * path2); |
this->serveStatic("/favicon.png", LittleFS, "/favicon.png"); | this->serveStatic("/favicon.png", LittleFS, "/favicon.png"); | ||||
return true; | return true; | ||||
} | |||||
} |
this->listRoot(); | this->listRoot(); | ||||
Serial.printf("\n\r"); | Serial.printf("\n\r"); | ||||
// https://stackoverflow.com/questions/7627098/what-is-a-lambda-expression-in-c11 | |||||
on("/compress.html", [this]() { | |||||
File f = open("/compress.html.gz"); | |||||
if (!f) { | |||||
Serial.println("Failed to open file for reading"); | |||||
} | |||||
else | |||||
{ | |||||
Serial.println("Streaming /compress.html.gz to client"); | |||||
const String cont = "text/html"; | |||||
streamFile(f, cont); | |||||
} | |||||
}); | |||||
if( this->addRootFileHandler() ){ | if( this->addRootFileHandler() ){ | ||||
this->begin(); | this->begin(); | ||||
Serial.printf("[HTTPServer] Server active on Port 80 !\n\r"); | Serial.printf("[HTTPServer] Server active on Port 80 !\n\r"); |
#include <Arduino.h> | |||||
// #include <Arduino.h> | |||||
#include "treppe.h" | #include "treppe.h" | ||||
#include <unity.h> | #include <unity.h> | ||||
Treppe stairs(10); | Treppe stairs(10); |