From 627d3ba8b5385377f8502399078767bb86ac4c26 Mon Sep 17 00:00:00 2001 From: tobi lutke Date: Sun, 25 Jun 2023 20:56:00 -0400 Subject: [PATCH] expose simple web interface on root domain demonstrates how to use the stream option of generate. --- examples/server/server.cpp | 9 +- examples/server/server.html | 287 ++++++++++++++++++++++++++++++++++++ 2 files changed, 295 insertions(+), 1 deletion(-) create mode 100644 examples/server/server.html diff --git a/examples/server/server.cpp b/examples/server/server.cpp index 3bf985957..2a492bdc9 100644 --- a/examples/server/server.cpp +++ b/examples/server/server.cpp @@ -889,7 +889,14 @@ int main(int argc, char ** argv) { }); svr.Get("/", [](const Request &, Response & res) { - res.set_content("

llama.cpp server works

", "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) { diff --git a/examples/server/server.html b/examples/server/server.html new file mode 100644 index 000000000..44b8db263 --- /dev/null +++ b/examples/server/server.html @@ -0,0 +1,287 @@ + + + + Llama.cpp + + + llama.cpp - chat + + + + + + + + + + + + \ No newline at end of file