mirror of
https://github.com/FraMecca/Buridans_donkey.git
synced 2024-03-20 11:20:15 +01:00
index.html
This commit is contained in:
parent
ffc6206737
commit
6a222780f4
1 changed files with 26 additions and 0 deletions
|
@ -73,12 +73,38 @@ if (gen == "/dev/random" || gen == "/dev/urandom")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum firstPage = `<h1> Buridan's Donkey </h1>
|
||||||
|
<blockquote>
|
||||||
|
...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.
|
||||||
|
</blockquote>
|
||||||
|
<p> This is the Buridan's Donkey main page.</p>
|
||||||
|
<p> Do not be afraid to ask for the help of the Donkey</p>
|
||||||
|
<p> you have four possibilities:<ul>
|
||||||
|
<li><a href="/x/true,false">/x/true,false</a>: to use Xorshift</li>
|
||||||
|
<li><a href="/mt/true,false">/mt/true,false</a>: to use Mersenne Twister</li>
|
||||||
|
<li><a href="/du/true,false">/du/true,false</a>: to use /dev/urandom</li>
|
||||||
|
<li><a href="/dr/true,false">/dr/true,false</a>: to use /dev/random</li>
|
||||||
|
</ul></p>
|
||||||
|
`;
|
||||||
|
|
||||||
|
void indexPage(scope HTTPServerRequest req, scope HTTPServerResponse res)
|
||||||
|
{
|
||||||
|
res.writeBody(firstPage);
|
||||||
|
}
|
||||||
|
|
||||||
void handleRequest(scope HTTPServerRequest req, scope HTTPServerResponse res)
|
void handleRequest(scope HTTPServerRequest req, scope HTTPServerResponse res)
|
||||||
{
|
{
|
||||||
void error(){
|
void error(){
|
||||||
|
immutable resp = "Invalid request.<br>For usage see <a href=\"/\">main page</a>";
|
||||||
res.statusCode = 400;
|
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;
|
immutable path = req.requestPath.bySegment.array;
|
||||||
if(path.length != 3){// path[0] == ""
|
if(path.length != 3){// path[0] == ""
|
||||||
error();
|
error();
|
||||||
|
|
Loading…
Reference in a new issue