expose simple web interface on root domain

demonstrates how to use the stream option of generate.
This commit is contained in:
tobi lutke 2023-06-25 20:56:00 -04:00 committed by Tobias Lütke
parent acc111caf9
commit 627d3ba8b5
No known key found for this signature in database
GPG key ID: 1FC0DBB14164709A
2 changed files with 295 additions and 1 deletions

View file

@ -889,7 +889,14 @@ int main(int argc, char ** argv) {
});
svr.Get("/", [](const Request &, Response & res) {
res.set_content("<h1>llama.cpp server works</h1>", "text/html");
// return content of server.html file
std::ifstream t("examples/server/server.html");
std::stringstream buffer;
buffer << t.rdbuf();
res.set_content(buffer.str(), "text/html");
return false;
});
svr.Post("/completion", [&llama](const Request & req, Response & res) {