My Marlin configs for Fabrikator Mini and CTC i3 Pro B
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

web.cpp 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /**
  2. * Marlin 3D Printer Firmware
  3. * Copyright (C) 2016 MarlinFirmware [https://github.com/MarlinFirmware/Marlin]
  4. * Copyright (c) 2016 Bob Cousins bobcousins42@googlemail.com
  5. *
  6. * This program is free software: you can redistribute it and/or modify
  7. * it under the terms of the GNU General Public License as published by
  8. * the Free Software Foundation, either version 3 of the License, or
  9. * (at your option) any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #ifdef ARDUINO_ARCH_ESP32
  20. #include "../../inc/MarlinConfigPre.h"
  21. #if ENABLED(WEBSUPPORT)
  22. #include "../../core/serial.h"
  23. #include "FS.h"
  24. #include "SPIFFS.h"
  25. #include "wifi.h"
  26. AsyncEventSource events("/events"); // event source (Server-Sent events)
  27. void onNotFound(AsyncWebServerRequest *request){
  28. request->send(404);
  29. }
  30. void web_init() {
  31. server.addHandler(&events); // attach AsyncEventSource
  32. if (SPIFFS.begin()) {
  33. server.serveStatic("/", SPIFFS, "/www").setDefaultFile("index.html");
  34. server.onNotFound(onNotFound);
  35. }
  36. else
  37. SERIAL_ECHO_MSG("SPIFFS Mount Failed");
  38. }
  39. #endif // WEBSUPPORT
  40. #endif // ARDUINO_ARCH_ESP32