cars.lua 2.1 KB

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