Skip to content

Add css style file #26

Answered by Hieromon
medic00 asked this question in Q&A
Apr 14, 2021 · 2 comments · 1 reply
Discussion options

You must be logged in to vote

Sketch

(It fits ESP32)

#include <Arduino.h>
#include <WiFi.h>
#include <WebServer.h>
#include <FS.h>
#include <SPIFFS.h>
#include <PageBuilder.h>

// You need to change the SSID and PASS to the actual strings that match your environment.
#define WIFI_SSID "****"
#define WIFI_PASS "****"

const char  _CONTENT_HELLO[] PROGMEM = R"(
<html>
<head>
  <style>
    {{STYLE}}
  </style>
</head>
<body>
  <div class="hello">
  Hello, world
  </div>
</body>
</html>
)";

// CSS files with the following names must be placed on SPIFFS
#define STYLE_FILENAME  "/hello.css"

String readStyle(PageArgument args) {
  String  css;
  if (SPIFFS.exists(STYLE_FILENAME)) {
    File  cf = SPIFFS.open(STYLE_FILENAME, "

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@medic00
Comment options

Answer selected by Hieromon
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants