Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ui2 build #503

Merged
merged 1 commit into from
Dec 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions scripts/extra_script.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ def data_to_header(env, target, source):
for source_file in source:
#print("Reading {}".format(source_file))
file = source_file.get_abspath()
if file.endswith(".css") or file.endswith(".js") or file.endswith(".htm") or file.endswith(".html") or file.endswith(".svg") or file.endswith(".json"):
output += text_to_header(file)
if file.endswith(".css") or file.endswith(".js") or file.endswith(".htm") or file.endswith(".html") or file.endswith(".svg") or file.endswith(".json") or file.endswith(".webmanifest"): output += text_to_header(file)
else:
output += binary_to_header(file)
target_file = target[0].get_abspath()
Expand All @@ -77,8 +76,7 @@ def filtered_listdir_scan(dir):
out_files = []
for file in listdir(dir):
path = join(dir, file)
if isfile(path) and (pathlib.Path(file).suffix in (".html", ".js", ".css", ".json", ".gz", ".png", ".jpg", ".ico")):
out_files.append(path)
if isfile(path) and (pathlib.Path(file).suffix in (".html", ".js", ".css", ".json", ".gz", ".png", ".jpg", ".ico", ".woff", ".woff2", ".webmanifest")): out_files.append(path)
elif isdir(path):
out_files.extend(filtered_listdir_scan(path))

Expand Down Expand Up @@ -138,6 +136,12 @@ def make_static(env, target, source):
filetype = "SVG"
elif out_file.endswith(".json") or out_file.endswith(".json.gz"):
filetype = "JSON"
elif out_file.endswith(".woff"):
filetype = "WOFF"
elif out_file.endswith(".woff2"):
filetype = "WOFF2"
elif out_file.endswith(".webmanifest"):
filetype = "MANIFEST"

if filetype is not None:
c_name = get_c_name(out_file)
Expand Down
21 changes: 12 additions & 9 deletions src/web_server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,15 +51,18 @@ static unsigned long wifiRestartTime = 0;
static unsigned long apOffTime = 0;

// Content Types
const char _CONTENT_TYPE_HTML[] PROGMEM = "text/html";
const char _CONTENT_TYPE_TEXT[] PROGMEM = "text/plain";
const char _CONTENT_TYPE_CSS[] PROGMEM = "text/css";
const char _CONTENT_TYPE_JSON[] PROGMEM = "application/json";
const char _CONTENT_TYPE_JS[] PROGMEM = "application/javascript";
const char _CONTENT_TYPE_JPEG[] PROGMEM = "image/jpeg";
const char _CONTENT_TYPE_PNG[] PROGMEM = "image/png";
const char _CONTENT_TYPE_SVG[] PROGMEM = "image/svg+xml";
const char _CONTENT_TYPE_ICO[] PROGMEM = "image/vnd.microsoft.icon";
const char _CONTENT_TYPE_HTML[] PROGMEM = "text/html";
const char _CONTENT_TYPE_TEXT[] PROGMEM = "text/plain";
const char _CONTENT_TYPE_CSS[] PROGMEM = "text/css";
const char _CONTENT_TYPE_JSON[] PROGMEM = "application/json";
const char _CONTENT_TYPE_JS[] PROGMEM = "text/javascript";
const char _CONTENT_TYPE_JPEG[] PROGMEM = "image/jpeg";
const char _CONTENT_TYPE_PNG[] PROGMEM = "image/png";
const char _CONTENT_TYPE_SVG[] PROGMEM = "image/svg+xml";
const char _CONTENT_TYPE_ICO[] PROGMEM = "image/vnd.microsoft.icon";
const char _CONTENT_TYPE_WOFF[] PROGMEM = "font/woff";
const char _CONTENT_TYPE_WOFF2[] PROGMEM = "font/woff2";
const char _CONTENT_TYPE_MANIFEST[] PROGMEM = "application/manifest+json";

#define RAPI_RESPONSE_BLOCKED -300

Expand Down
9 changes: 9 additions & 0 deletions src/web_server.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,15 @@ extern const char _CONTENT_TYPE_SVG[];
extern const char _CONTENT_TYPE_ICO[];
#define CONTENT_TYPE_ICO FPSTR(_CONTENT_TYPE_ICO)

extern const char _CONTENT_TYPE_WOFF[];
#define CONTENT_TYPE_WOFF FPSTR(_CONTENT_TYPE_WOFF)

extern const char _CONTENT_TYPE_WOFF2[];
#define CONTENT_TYPE_WOFF2 FPSTR(_CONTENT_TYPE_WOFF2)

extern const char _CONTENT_TYPE_MANIFEST[];
#define CONTENT_TYPE_MANIFEST FPSTR(_CONTENT_TYPE_MANIFEST)

extern MongooseHttpServer server;

extern void web_server_setup();
Expand Down