Merge pull request #10 from cirk2/master

Add Options enpoints and Access-Control-Allow-Headers to satisfy CORS
This commit is contained in:
Randall Fitzgerald 2023-06-01 08:10:26 -04:00 committed by GitHub
commit 797155a0d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -719,7 +719,10 @@ int main(int argc, char **argv)
Server svr;
svr.set_default_headers({ {"Access-Control-Allow-Origin", "*"} });
svr.set_default_headers({
{"Access-Control-Allow-Origin", "*"},
{"Access-Control-Allow-Headers", "content-type"}
});
svr.Get("/", [](const Request &, Response &res)
{ res.set_content("<h1>llama.cpp server works</h1>", "text/html"); });
@ -874,6 +877,11 @@ int main(int argc, char **argv)
}
});
svr.Options(R"(/.*)", [&llama](const Request &req, Response &res)
{
return res.set_content("", "application/json");
});
svr.Post("/tokenize", [&llama](const Request &req, Response &res)
{
json body = json::parse(req.body);