index.php 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>SampleREST</title>
  6. <style>
  7. body {
  8. margin: 0px;
  9. padding: 0px;
  10. background: #222;
  11. color: white;
  12. font-size: 18px;
  13. font-family: sans-serif;
  14. }
  15. h1 {
  16. color: orange;
  17. }
  18. .container {
  19. width: 60%;
  20. margin-left: 10%;
  21. margin-right: 10%;
  22. margin-top: 40px;
  23. margin-bottom: 40px;
  24. padding-left: 10%;
  25. padding-right: 10%;
  26. padding-top: 20px;
  27. padding-bottom: 20px;
  28. border-radius: 20px;
  29. border: 2px solid orange;
  30. }
  31. a {
  32. color: white;
  33. font-weight: bold;
  34. transition: color 0.5s;
  35. }
  36. a:hover {
  37. color: gray;
  38. }
  39. </style>
  40. <script type="text/javascript">
  41. document.addEventListener("DOMContentLoaded", () => {
  42. const list_to_prepare = document.querySelector(".copy-from");
  43. let home_location = document.location.toString();
  44. if (home_location[home_location.length - 1] != "/") {
  45. home_location += "/";
  46. }
  47. list_to_prepare.childNodes.forEach(link => {
  48. link.innerText = home_location + link.innerText;
  49. });
  50. });
  51. </script>
  52. </head>
  53. <body>
  54. <div class="container">
  55. <h1>Hello!</h1>
  56. <p>
  57. This is sample, super simple REST api for tutorial. It could
  58. response in JSON, HTML and send You JSON response with data
  59. sentnby data in HTTP body (POST) or by parameters given in
  60. URL (GET).
  61. </p>
  62. </div>
  63. <ul class="container">
  64. <li>
  65. <a href="./get">/get</a> - This return You JSON with
  66. data sent by URL parameters (GET).
  67. </li>
  68. <li>
  69. <a href="./post">/post</a> - This return You JSON with
  70. data sent by body of HTTP request (POST).
  71. </li>
  72. <li>
  73. <a href="./sample">/sample</a> - This return You sample
  74. static JSON.
  75. </li>
  76. <li>
  77. <a href="./html-sample">/html-sample</a> - This return You
  78. static HTML response.
  79. </li>
  80. <li>
  81. <a href="./plain-sample">/raw-sample</a> - This return You
  82. static text/plain response.
  83. </li>
  84. </ul>
  85. <div class="container">
  86. <h4>You can copy endpoints from list:</h4>
  87. <ul class="copy-from">
  88. <li>get</li>
  89. <li>post</li>
  90. <li>sample</li>
  91. <li>html-sample</li>
  92. <li>plain-sample</li>
  93. </ul>
  94. </div>
  95. </body>
  96. </html>