Merge pull request #10 from cirk2/master
Add Options enpoints and Access-Control-Allow-Headers to satisfy CORS
This commit is contained in:
commit
797155a0d1
1 changed files with 9 additions and 1 deletions
|
@ -719,7 +719,10 @@ int main(int argc, char **argv)
|
||||||
|
|
||||||
Server svr;
|
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)
|
svr.Get("/", [](const Request &, Response &res)
|
||||||
{ res.set_content("<h1>llama.cpp server works</h1>", "text/html"); });
|
{ 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)
|
svr.Post("/tokenize", [&llama](const Request &req, Response &res)
|
||||||
{
|
{
|
||||||
json body = json::parse(req.body);
|
json body = json::parse(req.body);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue