|
| 1 | +return function (connection, req, args) |
| 2 | + |
| 3 | + local function showCars(nr) |
| 4 | + if not nr then return end |
| 5 | + connection:send([===[<figure><img src="cars-ferrari.jpg" /><figcaption>Ferrari</figcaption></figure>]===]) |
| 6 | + if nr == "1" then return end |
| 7 | + connection:send([===[<figure><img src="cars-lambo.jpg" /><figcaption>Lamborghini</figcaption></figure>]===]) |
| 8 | + if nr == "2" then return end |
| 9 | + connection:send([===[<figure><img src="cars-mas.jpg" /><figcaption>Maserati</figcaption></figure>]===]) |
| 10 | + if nr == "3" then return end |
| 11 | + connection:send([===[<figure><img src="cars-porsche.jpg" /><figcaption>Porsche</figcaption></figure>]===]) |
| 12 | + if nr == "4" then return end |
| 13 | + connection:send([===[<figure><img src="cars-bugatti.jpg" /><figcaption>Bugatti</figcaption></figure>]===]) |
| 14 | + if nr == "5" then return end |
| 15 | + connection:send([===[<figure><img src="cars-mercedes.jpg" /><figcaption>Mercedes</figcaption></figure>]===]) |
| 16 | + end |
| 17 | + |
| 18 | + |
| 19 | + dofile("httpserver-header.lc")(connection, 200, 'html') |
| 20 | + connection:send([===[ |
| 21 | +<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> |
| 22 | +<html lang="en"> |
| 23 | + <head> |
| 24 | + <meta http-equiv="content-type" content="text/html; charset=utf-8"> |
| 25 | + <title>Nice cars</title> |
| 26 | + </head> |
| 27 | + <body> |
| 28 | + <h1>Nice cars!</h1> |
| 29 | + <p> |
| 30 | + This page loads "large" images of fancy cars. It is meant to serve as a stress test for nodemcu-httpserver.<br> |
| 31 | + 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> |
| 32 | + Whoever manages to modify nodemcu-httpserver to load all four images without crashing wins a prize! |
| 33 | + </p> |
| 34 | + <p> |
| 35 | + choose: <a href="?n=1">show one car</a> |
| 36 | + <a href="?n=2">show two cars</a> |
| 37 | + <a href="?n=3">show three cars</a> |
| 38 | + <a href="?n=4">show four cars</a> |
| 39 | + <a href="?n=5">show five cars</a> |
| 40 | + <a href="?n=6">show six cars</a> |
| 41 | + </p> |
| 42 | + ]===]) |
| 43 | + |
| 44 | + showCars(args.n) |
| 45 | + |
| 46 | + connection:send([===[ |
| 47 | + </body> |
| 48 | +</html> |
| 49 | + ]===]) |
| 50 | +end |
| 51 | + |
0 commit comments