Browse Source

moved files, this in on callback for httpserver class

tags/FSM1.0
Simon Schmidt 3 years ago
parent
commit
e8329f2587

BIN
data/compress.html.gz View File


+ 7
- 2
lib/httpserver/filesys.cpp View File

@@ -4,7 +4,7 @@
// deleteFile("/hello.txt");
// writeFile("/hello.txt", "Hello ");
// appendFile("/hello.txt", "World!\n\r");
// readFile("/hello.txt");
// printFile("/hello.txt");
// listDir("/");

FSInfo fsinfo;
@@ -58,7 +58,12 @@ void ls(const char * dirname) {
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);

File file = LittleFS.open(path, "r");

+ 3
- 1
lib/httpserver/filesys.h View File

@@ -5,8 +5,10 @@
bool mount_fs();
bool format_fs();

File open(const char * path);

void ls(const char * dirname);
void readFile(const char * path);
void printFile(const char * path);
void writeFile(const char * path, const char * message);
void appendFile(const char * path, const char * message);
void renameFile(const char * path1, const char * path2);

+ 1
- 1
lib/httpserver/httpserver.cpp View File

@@ -14,4 +14,4 @@ bool HTTPServer::addRootFileHandler() {
this->serveStatic("/favicon.png", LittleFS, "/favicon.png");

return true;
}
}

+ 14
- 0
lib/httpserver/httpserver.h View File

@@ -33,6 +33,20 @@ public:
this->listRoot();
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() ){
this->begin();
Serial.printf("[HTTPServer] Server active on Port 80 !\n\r");

+ 1
- 2
test/test_pwm.cpp View File

@@ -1,6 +1,5 @@
#include <Arduino.h>
// #include <Arduino.h>
#include "treppe.h"

#include <unity.h>

Treppe stairs(10);

Loading…
Cancel
Save