@@ -4800,20 +4800,22 @@ int main(int argc, char ** argv) {
48004800 // Router
48014801 //
48024802
4803+ const char * server_prefix = params.server_prefix .c_str ();
4804+
48034805 if (!params.webui ) {
48044806 LOG_INF (" Web UI is disabled\n " );
48054807 } else {
48064808 // register static assets routes
48074809 if (!params.public_path .empty ()) {
48084810 // Set the base directory for serving static files
4809- bool is_found = svr->set_mount_point (" / " , params.public_path );
4811+ bool is_found = svr->set_mount_point (string_format ( " %s/ " , server_prefix) , params.public_path );
48104812 if (!is_found) {
48114813 LOG_ERR (" %s: static assets path not found: %s\n " , __func__, params.public_path .c_str ());
48124814 return 1 ;
48134815 }
48144816 } else {
48154817 // using embedded static index.html
4816- svr->Get (" / " , [](const httplib::Request & req, httplib::Response & res) {
4818+ svr->Get (string_format ( " %s/ " , server_prefix) , [](const httplib::Request & req, httplib::Response & res) {
48174819 if (req.get_header_value (" Accept-Encoding" ).find (" gzip" ) == std::string::npos) {
48184820 res.set_content (" Error: gzip is not supported by this browser" , " text/plain" );
48194821 } else {
@@ -4829,37 +4831,37 @@ int main(int argc, char ** argv) {
48294831 }
48304832
48314833 // register API routes
4832- svr->Get (" /health" , handle_health); // public endpoint (no API key check)
4833- svr->Get (" /metrics" , handle_metrics);
4834- svr->Get (" /props" , handle_props);
4835- svr->Post (" /props" , handle_props_change);
4836- svr->Post (" /api/show" , handle_api_show);
4837- svr->Get (" /models" , handle_models); // public endpoint (no API key check)
4838- svr->Get (" /v1/models" , handle_models); // public endpoint (no API key check)
4839- svr->Get (" /api/tags" , handle_models); // ollama specific endpoint. public endpoint (no API key check)
4840- svr->Post (" /completion" , handle_completions); // legacy
4841- svr->Post (" /completions" , handle_completions);
4842- svr->Post (" /v1/completions" , handle_completions_oai);
4843- svr->Post (" /chat/completions" , handle_chat_completions);
4844- svr->Post (" /v1/chat/completions" , handle_chat_completions);
4845- svr->Post (" /api/chat" , handle_chat_completions); // ollama specific endpoint
4846- svr->Post (" /infill" , handle_infill);
4847- svr->Post (" /embedding" , handle_embeddings); // legacy
4848- svr->Post (" /embeddings" , handle_embeddings);
4849- svr->Post (" /v1/embeddings" , handle_embeddings_oai);
4850- svr->Post (" /rerank" , handle_rerank);
4851- svr->Post (" /reranking" , handle_rerank);
4852- svr->Post (" /v1/rerank" , handle_rerank);
4853- svr->Post (" /v1/reranking" , handle_rerank);
4854- svr->Post (" /tokenize" , handle_tokenize);
4855- svr->Post (" /detokenize" , handle_detokenize);
4856- svr->Post (" /apply-template" , handle_apply_template);
4834+ svr->Get (string_format ( " %s /health" , server_prefix) , handle_health); // public endpoint (no API key check)
4835+ svr->Get (string_format ( " %s /metrics" , server_prefix) , handle_metrics);
4836+ svr->Get (string_format ( " %s /props" , server_prefix) , handle_props);
4837+ svr->Post (string_format ( " %s /props" , server_prefix) , handle_props_change);
4838+ svr->Post (string_format ( " %s /api/show" , server_prefix) , handle_api_show);
4839+ svr->Get (string_format ( " %s /models" , server_prefix) , handle_models); // public endpoint (no API key check)
4840+ svr->Get (string_format ( " %s /v1/models" , server_prefix) , handle_models); // public endpoint (no API key check)
4841+ svr->Get (string_format ( " %s /api/tags" , server_prefix) , handle_models); // ollama specific endpoint. public endpoint (no API key check)
4842+ svr->Post (string_format ( " %s /completion" , server_prefix) , handle_completions); // legacy
4843+ svr->Post (string_format ( " %s /completions" , server_prefix) , handle_completions);
4844+ svr->Post (string_format ( " %s /v1/completions" , server_prefix) , handle_completions_oai);
4845+ svr->Post (string_format ( " %s /chat/completions" , server_prefix) , handle_chat_completions);
4846+ svr->Post (string_format ( " %s /v1/chat/completions" , server_prefix) , handle_chat_completions);
4847+ svr->Post (string_format ( " %s /api/chat" , server_prefix) , handle_chat_completions); // ollama specific endpoint
4848+ svr->Post (string_format ( " %s /infill" , server_prefix) , handle_infill);
4849+ svr->Post (string_format ( " %s /embedding" , server_prefix) , handle_embeddings); // legacy
4850+ svr->Post (string_format ( " %s /embeddings" , server_prefix) , handle_embeddings);
4851+ svr->Post (string_format ( " %s /v1/embeddings" , server_prefix) , handle_embeddings_oai);
4852+ svr->Post (string_format ( " %s /rerank" , server_prefix) , handle_rerank);
4853+ svr->Post (string_format ( " %s /reranking" , server_prefix) , handle_rerank);
4854+ svr->Post (string_format ( " %s /v1/rerank" , server_prefix) , handle_rerank);
4855+ svr->Post (string_format ( " %s /v1/reranking" , server_prefix) , handle_rerank);
4856+ svr->Post (string_format ( " %s /tokenize" , server_prefix) , handle_tokenize);
4857+ svr->Post (string_format ( " %s /detokenize" , server_prefix) , handle_detokenize);
4858+ svr->Post (string_format ( " %s /apply-template" , server_prefix) , handle_apply_template);
48574859 // LoRA adapters hotswap
4858- svr->Get (" /lora-adapters" , handle_lora_adapters_list);
4859- svr->Post (" /lora-adapters" , handle_lora_adapters_apply);
4860+ svr->Get (string_format ( " %s /lora-adapters" , server_prefix) , handle_lora_adapters_list);
4861+ svr->Post (string_format ( " %s /lora-adapters" , server_prefix) , handle_lora_adapters_apply);
48604862 // Save & load slots
4861- svr->Get (" /slots" , handle_slots);
4862- svr->Post (" /slots/:id_slot" , handle_slots_action);
4863+ svr->Get (string_format ( " %s /slots" , server_prefix) , handle_slots);
4864+ svr->Post (string_format ( " %s /slots/:id_slot" , server_prefix) , handle_slots_action);
48634865
48644866 //
48654867 // Start the server
0 commit comments