template indedx.html added
This commit is contained in:
parent
87c40f4e5a
commit
2b15f5d8ea
13
main.cpp
13
main.cpp
|
@ -5,7 +5,7 @@
|
||||||
#include "mstch/mstch.hpp"
|
#include "mstch/mstch.hpp"
|
||||||
#include "ext/format.h"
|
#include "ext/format.h"
|
||||||
|
|
||||||
#include <iostream>
|
#include <fstream>
|
||||||
|
|
||||||
using boost::filesystem::path;
|
using boost::filesystem::path;
|
||||||
|
|
||||||
|
@ -42,12 +42,11 @@ int main() {
|
||||||
fmt::print("\n\n"
|
fmt::print("\n\n"
|
||||||
"Top block height : {:d}\n", height);
|
"Top block height : {:d}\n", height);
|
||||||
|
|
||||||
std::string view {
|
std::ifstream t("src/templates/index.html");
|
||||||
"Blockchain height {{height}}\n\n"
|
std::string index_tmpl_str((std::istreambuf_iterator<char>(t)),
|
||||||
"{{#blocks}}{{height}}: {{hash}} \n{{/blocks}}"
|
std::istreambuf_iterator<char>());
|
||||||
};
|
|
||||||
|
|
||||||
mstch::map context {
|
mstch::map context {
|
||||||
{"height", fmt::format("{:d}", height)},
|
{"height", fmt::format("{:d}", height)},
|
||||||
{"blocks", mstch::array()}
|
{"blocks", mstch::array()}
|
||||||
};
|
};
|
||||||
|
@ -73,7 +72,7 @@ int main() {
|
||||||
|
|
||||||
CROW_ROUTE(app, "/")
|
CROW_ROUTE(app, "/")
|
||||||
([&]() {
|
([&]() {
|
||||||
return mstch::render(view, context);
|
return mstch::render(index_tmpl_str, context);
|
||||||
});
|
});
|
||||||
|
|
||||||
app.port(8080).multithreaded().run();
|
app.port(8080).multithreaded().run();
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<title>Monero blocks</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div>
|
||||||
|
<h1>{{height}}</h1>
|
||||||
|
<div>
|
||||||
|
{{#blocks}}
|
||||||
|
{{height}}: {{hash}}
|
||||||
|
{{/blocks}}
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
Loading…
Reference in New Issue