feat: add very simple index page linking to my site
ci/woodpecker/push/woodpecker Pipeline was successful Details

trie-skips
Jef Roosens 2022-11-27 19:49:38 +01:00
parent 22a7b5b3fc
commit 55474b485f
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
1 changed files with 13 additions and 0 deletions

View File

@ -7,6 +7,16 @@ extern "C" {
#include "ternarytrie.h" #include "ternarytrie.h"
} }
static const std::string index_page = R"(
<!DOCTYPE html>
<html>
<body>
<h1>r8r.be</h1>
<p>This is the URL shortener and pastebin accompanying my site, <a href="https://rustybever.be">The Rusty Bever</a>.</p>
</body>
</html>
)";
#define ENV(var, env_var) \ #define ENV(var, env_var) \
const char *_##var = getenv(env_var); \ const char *_##var = getenv(env_var); \
if (_##var == NULL) { \ if (_##var == NULL) { \
@ -102,6 +112,9 @@ int main() {
crow::SimpleApp app; crow::SimpleApp app;
app.loglevel(crow::LogLevel::Info); app.loglevel(crow::LogLevel::Info);
CROW_ROUTE(app, "/").methods(crow::HTTPMethod::Get)(
[]() { return crow::response("html", index_page); });
// Serve an entry // Serve an entry
CROW_ROUTE(app, "/<string>") CROW_ROUTE(app, "/<string>")
.methods(crow::HTTPMethod::Get)( .methods(crow::HTTPMethod::Get)(