Gregor Hartmann 5cf303de79 make cars dynamic to load 1 to 6 cars (#114)
For lazy people like me for not having to change the page by hand every
time.
+ adding 2 more cars.
2017-10-02 11:15:12 -05:00

52 lines
2.1 KiB
Lua

return function (connection, req, args)
local function showCars(nr)
if not nr then return end
connection:send([===[<figure><img src="cars-ferrari.jpg" /><figcaption>Ferrari</figcaption></figure>]===])
if nr == "1" then return end
connection:send([===[<figure><img src="cars-lambo.jpg" /><figcaption>Lamborghini</figcaption></figure>]===])
if nr == "2" then return end
connection:send([===[<figure><img src="cars-mas.jpg" /><figcaption>Maserati</figcaption></figure>]===])
if nr == "3" then return end
connection:send([===[<figure><img src="cars-porsche.jpg" /><figcaption>Porsche</figcaption></figure>]===])
if nr == "4" then return end
connection:send([===[<figure><img src="cars-bugatti.jpg" /><figcaption>Bugatti</figcaption></figure>]===])
if nr == "5" then return end
connection:send([===[<figure><img src="cars-mercedes.jpg" /><figcaption>Mercedes</figcaption></figure>]===])
end
dofile("httpserver-header.lc")(connection, 200, 'html')
connection:send([===[
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>Nice cars</title>
</head>
<body>
<h1>Nice cars!</h1>
<p>
This page loads "large" images of fancy cars. It is meant to serve as a stress test for nodemcu-httpserver.<br>
It works with three embedded images of cars, but the server crashes with four. Select the number of cars you want to see below.<br>
Whoever manages to modify nodemcu-httpserver to load all four images without crashing wins a prize!
</p>
<p>
choose: <a href="?n=1">show one car</a>
<a href="?n=2">show two cars</a>
<a href="?n=3">show three cars</a>
<a href="?n=4">show four cars</a>
<a href="?n=5">show five cars</a>
<a href="?n=6">show six cars</a>
</p>
]===])
showCars(args.n)
connection:send([===[
</body>
</html>
]===])
end