cars.lua 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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>
  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. OK I guess I win the prize, as now you can load five cars.<br>
  33. Cheers HHHartmann
  34. </p>
  35. <p>
  36. choose: <a href="?n=1">show one car</a>
  37. <a href="?n=2">show two cars</a>
  38. <a href="?n=3">show three cars</a>
  39. <a href="?n=4">show four cars</a>
  40. <a href="?n=5">show five cars</a>
  41. <a href="?n=6">show six cars</a>
  42. </p>
  43. ]===])
  44. showCars(args.n)
  45. connection:send([===[
  46. </body>
  47. </html>
  48. ]===])
  49. end