Skip to content

Commit c51d2cc

Browse files
committed
更新固件页面的优化
1 parent 795c41b commit c51d2cc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/main.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,9 +34,9 @@ String psw;
3434
CSE7766 myCSE7766;
3535
const int httpPort = 80;
3636
String deviceName = "斐讯DC1插排";
37-
String version = "1.1";
37+
String version = "1.2";
3838
ESP8266WebServer server(httpPort);
39-
const char* serverIndex = "<h1>更新固件:</h1><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' name='update'><input type='submit' value='开始上传升级'></form>";
39+
const char* serverIndex = "<!DOCTYPE html><html><head><meta charset='utf-8'><title>更新固件</title></head><body><h1>更新固件:</h1><form method='POST' action='/update' enctype='multipart/form-data'><input type='file' name='update'><input type='submit' value='开始上传升级'></form></body></html>";
4040
// 开关的当前状态
4141
bool logLedStatus = true;
4242
bool wifiLedStatus = true;
@@ -318,6 +318,11 @@ void setup(void){
318318

319319
server.on("/cse7766", handleCSE7766);
320320

321+
server.on("/update", HTTP_GET, []() {
322+
server.sendHeader("Connection", "close");
323+
server.send(200, "text/html", "固件更新成功,新版本:" + version);
324+
}
325+
);
321326
server.on("/update", HTTP_POST, []() {
322327
server.sendHeader("Connection", "close");
323328
server.send(200, "text/plain", (Update.hasError()) ? "{\"code\":1,\"message\":\"fail\"}" : "{\"code\":0,\"message\":\"success\"}");

0 commit comments

Comments
 (0)