From 6a222780f4587ad095107c120c019da5ea63680f Mon Sep 17 00:00:00 2001
From: Francesco Mecca
Date: Sat, 27 Apr 2019 10:04:00 +0200
Subject: [PATCH] index.html
---
web/source/app.d | 26 ++++++++++++++++++++++++++
1 file changed, 26 insertions(+)
diff --git a/web/source/app.d b/web/source/app.d
index 3491ee3..f7f2f07 100644
--- a/web/source/app.d
+++ b/web/source/app.d
@@ -73,12 +73,38 @@ if (gen == "/dev/random" || gen == "/dev/urandom")
}
}
+enum firstPage = ` Buridan's Donkey
+
+...a man, being just as hungry as thirsty, and placed in between food and drink, must necessarily remain where he is and starve to death.
+
+ This is the Buridan's Donkey main page.
+ Do not be afraid to ask for the help of the Donkey
+ you have four possibilities:
+`;
+
+void indexPage(scope HTTPServerRequest req, scope HTTPServerResponse res)
+{
+ res.writeBody(firstPage);
+}
+
void handleRequest(scope HTTPServerRequest req, scope HTTPServerResponse res)
{
void error(){
+ immutable resp = "Invalid request.
For usage see main page";
res.statusCode = 400;
+ res.writeBody(resp);
}
+ res.headers["Content-Type"] = "text/html";
+
+ if(req.path == "/" || req.path == "/index.html")
+ return indexPage(req, res);
+
immutable path = req.requestPath.bySegment.array;
if(path.length != 3){// path[0] == ""
error();