Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
26 changes: 26 additions & 0 deletions src/gigagrad_viz_server.cpp
Original file line number Diff line number Diff line change
@@ -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;
}
10 changes: 10 additions & 0 deletions subprojects/nlohmann_json.wrap
Original file line number Diff line number Diff line change
@@ -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