Skip to content

Commit a7feae7

Browse files
committed
also support .html files
1 parent 739ea75 commit a7feae7

File tree

4 files changed

+18
-2
lines changed

4 files changed

+18
-2
lines changed

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1440,6 +1440,7 @@ llama-server: \
14401440
examples/server/system-prompts.js.hpp \
14411441
examples/server/prompt-formats.js.hpp \
14421442
examples/server/json-schema-to-grammar.mjs.hpp \
1443+
examples/server/loading.html.hpp \
14431444
common/json.hpp \
14441445
common/stb_image.h \
14451446
$(OBJ_ALL)

examples/server/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ set(PUBLIC_ASSETS
3030
system-prompts.js
3131
prompt-formats.js
3232
json-schema-to-grammar.mjs
33+
loading.html
3334
)
3435

3536
foreach(asset ${PUBLIC_ASSETS})
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<meta http-equiv="refresh" content="5">
5+
</head>
6+
<body>
7+
<div id="loading">
8+
The model is loading. Please wait.<br/>
9+
The user interface will appear soon.
10+
</div>
11+
</body>
12+
</html>

examples/server/server.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
#include "system-prompts.js.hpp"
2929
#include "prompt-formats.js.hpp"
3030
#include "json-schema-to-grammar.mjs.hpp"
31+
#include "loading.html.hpp"
3132

3233
#include <atomic>
3334
#include <chrono>
@@ -2595,8 +2596,9 @@ int main(int argc, char ** argv) {
25952596
auto middleware_server_state = [&res_error, &state](const httplib::Request & req, httplib::Response & res) {
25962597
server_state current_state = state.load();
25972598
if (current_state == SERVER_STATE_LOADING_MODEL) {
2598-
if(req.path == "/"){
2599-
res.set_content("<html><body>The model is loading. Please wait.<br/>The user interface will appear soon.<br/>You may need to refresh the page.</body></html>", "text/html; charset=utf-8");
2599+
auto tmp = string_split(req.path, '.');
2600+
if (req.path == "/" || tmp.back() == "html") {
2601+
res.set_content(reinterpret_cast<const char*>(loading_html), loading_html_len, "text/html; charset=utf-8");
26002602
res.status = 503;
26012603
} else {
26022604
res_error(res, format_error_response("Loading model", ERROR_TYPE_UNAVAILABLE));

0 commit comments

Comments
 (0)