summaryrefslogtreecommitdiff
path: root/examples/server/server.cpp
diff options
context:
space:
mode:
authorJhen-Jie Hong <iainst0409@gmail.com>2023-08-15 06:14:14 +0800
committerGitHub <noreply@github.com>2023-08-15 06:14:14 +0800
commit3ebb00935f3f0522b75df49c2769ab1774b91380 (patch)
treee40d83e824e43bee03ac89400773ca5aeba54c09 /examples/server/server.cpp
parentd783f7982e0e823a2626a9956359c0d36c1a7e21 (diff)
server : add missing /json-schema-to-grammar.mjs (#2616)
fixes #2611
Diffstat (limited to 'examples/server/server.cpp')
-rw-r--r--examples/server/server.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/examples/server/server.cpp b/examples/server/server.cpp
index 222dbcb4..99660455 100644
--- a/examples/server/server.cpp
+++ b/examples/server/server.cpp
@@ -15,6 +15,7 @@
#include "index.html.hpp"
#include "index.js.hpp"
#include "completion.js.hpp"
+#include "json-schema-to-grammar.mjs.hpp"
#ifndef SERVER_VERBOSE
#define SERVER_VERBOSE 1
@@ -1218,6 +1219,12 @@ int main(int argc, char **argv)
res.set_content(reinterpret_cast<const char*>(&completion_js), completion_js_len, "application/javascript");
return false; });
+ // this is only called if no index.html is found in the public --path
+ svr.Get("/json-schema-to-grammar.mjs", [](const Request &, Response &res)
+ {
+ res.set_content(reinterpret_cast<const char*>(&json_schema_to_grammar_mjs), json_schema_to_grammar_mjs_len, "application/javascript");
+ return false; });
+
svr.Post("/completion", [&llama](const Request &req, Response &res)
{
auto lock = llama.lock();