Skip to content
Closed
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
9 changes: 7 additions & 2 deletions examples/server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2592,10 +2592,15 @@ int main(int argc, char ** argv) {
return false;
};

auto middleware_server_state = [&res_error, &state](const httplib::Request &, httplib::Response & res) {
auto middleware_server_state = [&res_error, &state](const httplib::Request & req, httplib::Response & res) {
server_state current_state = state.load();
if (current_state == SERVER_STATE_LOADING_MODEL) {
res_error(res, format_error_response("Loading model", ERROR_TYPE_UNAVAILABLE));
if(req.path == "/"){
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're missing one requirement from the original issue #9158

Here only / is catched, not *.html. I leave a suggestion on my comment #9401 (comment) , but I'll apply it myself.

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");
res.status = 503;
} else {
res_error(res, format_error_response("Loading model", ERROR_TYPE_UNAVAILABLE));
}
return false;
}
return true;
Expand Down
Loading