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