server : add flag to disable the web-ui (#10762) (#10751)

Co-authored-by: eugenio.segala <esegala@deloitte.co.uk>
This commit is contained in:
Yüg 2024-12-10 17:22:34 +00:00 committed by GitHub
parent a05e2afcc2
commit a86ad841f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 46 additions and 13 deletions

View file

@ -3815,20 +3815,24 @@ int main(int argc, char ** argv) {
// Router
//
// register static assets routes
if (!params.public_path.empty()) {
// Set the base directory for serving static files
bool is_found = svr->set_mount_point("/", params.public_path);
if (!is_found) {
LOG_ERR("%s: static assets path not found: %s\n", __func__, params.public_path.c_str());
return 1;
}
if (!params.webui) {
LOG_INF("Web UI is disabled\n");
} else {
// using embedded static index.html
svr->Get("/", [](const httplib::Request &, httplib::Response & res) {
res.set_content(reinterpret_cast<const char*>(index_html), index_html_len, "text/html; charset=utf-8");
return false;
});
// register static assets routes
if (!params.public_path.empty()) {
// Set the base directory for serving static files
bool is_found = svr->set_mount_point("/", params.public_path);
if (!is_found) {
LOG_ERR("%s: static assets path not found: %s\n", __func__, params.public_path.c_str());
return 1;
}
} else {
// using embedded static index.html
svr->Get("/", [](const httplib::Request &, httplib::Response & res) {
res.set_content(reinterpret_cast<const char*>(index_html), index_html_len, "text/html; charset=utf-8");
return false;
});
}
}
// register API routes