From 2b15f5d8ea4d6bda7cc4e7ff54540b3a698fdff2 Mon Sep 17 00:00:00 2001 From: moneroexamples Date: Thu, 7 Apr 2016 15:01:49 +0800 Subject: [PATCH] template indedx.html added --- main.cpp | 13 ++++++------- src/templates/index.html | 17 +++++++++++++++++ 2 files changed, 23 insertions(+), 7 deletions(-) create mode 100644 src/templates/index.html diff --git a/main.cpp b/main.cpp index c1b0f5c..0214043 100644 --- a/main.cpp +++ b/main.cpp @@ -5,7 +5,7 @@ #include "mstch/mstch.hpp" #include "ext/format.h" -#include +#include using boost::filesystem::path; @@ -42,12 +42,11 @@ int main() { fmt::print("\n\n" "Top block height : {:d}\n", height); - std::string view { - "Blockchain height {{height}}\n\n" - "{{#blocks}}{{height}}: {{hash}} \n{{/blocks}}" - }; + std::ifstream t("src/templates/index.html"); + std::string index_tmpl_str((std::istreambuf_iterator(t)), + std::istreambuf_iterator()); - mstch::map context { + mstch::map context { {"height", fmt::format("{:d}", height)}, {"blocks", mstch::array()} }; @@ -73,7 +72,7 @@ int main() { CROW_ROUTE(app, "/") ([&]() { - return mstch::render(view, context); + return mstch::render(index_tmpl_str, context); }); app.port(8080).multithreaded().run(); diff --git a/src/templates/index.html b/src/templates/index.html new file mode 100644 index 0000000..9f4367f --- /dev/null +++ b/src/templates/index.html @@ -0,0 +1,17 @@ + + + + + Monero blocks + + +
+

{{height}}

+
+ {{#blocks}} + {{height}}: {{hash}} + {{/blocks}} +
+
+ + \ No newline at end of file