diff --git a/meson.build b/meson.build index 47f07c6..b8c86e0 100644 --- a/meson.build +++ b/meson.build @@ -2,7 +2,7 @@ project('gigagrad', 'cpp', default_options : ['cpp_std=c++20']) gigagrad = library('gigagrad', 'src/graph.cpp') test_deps = [dependency('catch2-with-main')] -vizserver_deps = [dependency('cpp-httplib')] +vizserver_deps = [dependency('cpp-httplib'), dependency('nlohmann_json')] executable('gigagrad-test', 'test/graph-test.cpp', dependencies : test_deps, link_with : gigagrad) executable('gigagrad-viz-server', 'src/gigagrad_viz_server.cpp', dependencies : vizserver_deps, diff --git a/src/gigagrad_viz_server.cpp b/src/gigagrad_viz_server.cpp index 6647d72..0423994 100644 --- a/src/gigagrad_viz_server.cpp +++ b/src/gigagrad_viz_server.cpp @@ -1,6 +1,32 @@ #include "httplib.h" +#include "nlohmann/json.hpp" + +using json = nlohmann::json; + + +void StartServer() { + httplib::Server svr; + + svr.Get("/test-tensor", [](const httplib::Request &, httplib::Response &res) { + const json test_tensor = { + {"shape", {1, 6, 6, 3}}, + {"buffer", { + 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, + 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, + 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, + 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, + 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, + 3, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8 + }} + }; + res.set_content(test_tensor.dump(), "application/json"); + }); + + svr.listen("0.0.0.0", 8080); +} int main() { + StartServer(); return 0; } diff --git a/subprojects/nlohmann_json.wrap b/subprojects/nlohmann_json.wrap new file mode 100644 index 0000000..bf5d700 --- /dev/null +++ b/subprojects/nlohmann_json.wrap @@ -0,0 +1,10 @@ +[wrap-file] +directory = nlohmann_json-3.11.2 +lead_directory_missing = true +source_url = https://github.com/nlohmann/json/releases/download/v3.11.2/include.zip +source_filename = nlohmann_json-3.11.2.zip +source_hash = e5c7a9f49a16814be27e4ed0ee900ecd0092bfb7dbfca65b5a421b774dccaaed +wrapdb_version = 3.11.2-1 + +[provide] +nlohmann_json = nlohmann_json_dep