Skip to content
This repository has been archived by the owner on Jan 11, 2020. It is now read-only.

Commit

Permalink
Fixed wrong mimetypes
Browse files Browse the repository at this point in the history
  • Loading branch information
merlinschumacher committed Jan 9, 2018
1 parent 8eba3ca commit e600737
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions WebServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@
#include "debug.hpp"

void WebServer::begin(Configuration &configuration) {


SPIFFS.begin();
server = new AsyncWebServer(80);
events = new AsyncEventSource("/events");
Expand Down Expand Up @@ -37,7 +35,7 @@ void WebServer::begin(Configuration &configuration) {
});

server->on("/basecamp.js" , HTTP_GET, [](AsyncWebServerRequest * request) {
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/css", basecamp_js_gz, basecamp_js_gz_len);
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/js", basecamp_js_gz, basecamp_js_gz_len);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
});
Expand Down Expand Up @@ -83,27 +81,27 @@ void WebServer::begin(Configuration &configuration) {
} else {
DEBUG_PRINTLN("No Config found");
server->on("/data.json" , HTTP_GET, [](AsyncWebServerRequest * request) {
AsyncWebServerResponse *response = request->beginResponse_P(200, "text/css", initconf_json_gz, initconf_json_gz_len);
AsyncWebServerResponse *response = request->beginResponse_P(200, "application/json", initconf_json_gz, initconf_json_gz_len);
response->addHeader("Content-Encoding", "gzip");
request->send(response);
});
}
server->on("/submitconfig", HTTP_POST, [&configuration](AsyncWebServerRequest * request) {
int params = request->params();
for(int i=0;i<params;i++){
AsyncWebParameter* p = request->getParam(i);
if(p->isPost()){
if(p->value().c_str() != "") {
configuration.set(p->name().c_str(), p->value().c_str());
}
}
AsyncWebParameter* p = request->getParam(i);
if(p->isPost()){
if(p->value().c_str() != "") {
configuration.set(p->name().c_str(), p->value().c_str());
}
}
}
configuration.save();
request->send(201);

delay(2000);
esp_restart();
});
});

server->onNotFound([](AsyncWebServerRequest * request) {
#ifdef DEBUG
Expand Down

0 comments on commit e600737

Please sign in to comment.