暂无描述
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  1. <!-- <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <title>Question Form</title>
  7. <style>
  8. body {
  9. font-family: Arial, sans-serif;
  10. margin: 0;
  11. padding: 0;
  12. }
  13. .form-container {
  14. max-width: 400px;
  15. margin: 50px auto;
  16. padding: 20px;
  17. border: 1px solid #ccc;
  18. border-radius: 5px;
  19. }
  20. label {
  21. display: block;
  22. margin-bottom: 8px;
  23. }
  24. input {
  25. width: 100%;
  26. padding: 8px;
  27. margin-bottom: 16px;
  28. box-sizing: border-box;
  29. }
  30. textarea {
  31. width: 100%;
  32. height: 100px;
  33. padding: 8px;
  34. margin-bottom: 16px;
  35. box-sizing: border-box;
  36. }
  37. button {
  38. padding: 8px 16px;
  39. background-color: #3498db;
  40. color: #fff;
  41. border: none;
  42. border-radius: 3px;
  43. cursor: pointer;
  44. }
  45. button:hover {
  46. background-color: #2980b9;
  47. }
  48. .output-container {
  49. margin-top: 20px;
  50. }
  51. </style>
  52. </head>
  53. <body>
  54. <div class="form-container">
  55. <form id="questionForm">
  56. <label for="userId">User ID:</label>
  57. <input type="text" id="userId" readonly>
  58. <label for="question">Question:</label>
  59. <textarea id="question" required></textarea>
  60. <button type="button" onclick="handleSubmit()">Submit</button>
  61. </form>
  62. <div class="output-container">
  63. <label for="output">Output:</label>
  64. <textarea id="output" readonly></textarea>
  65. </div>
  66. </div>
  67. <script>
  68. function generateUserId() {
  69. // Generate a random user ID
  70. var userId = "User" + Math.floor(Math.random() * 10000);
  71. document.getElementById("userId").value = userId;
  72. }
  73. function handleSubmit() {
  74. // Get values from the form
  75. var userId = document.getElementById("userId").value;
  76. var question = document.getElementById("question").value;
  77. // Make an AJAX request to the server
  78. var xhr = new XMLHttpRequest();
  79. xhr.open("POST", "/user_input", true);
  80. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  81. xhr.onreadystatechange = function () {
  82. if (xhr.readyState == 4 && xhr.status == 200) {
  83. // Parse the JSON response
  84. var response = JSON.parse(xhr.responseText);
  85. // Update the output textarea with question and answer
  86. var output = "Question: " + question + "\nAnswer: " + response.output;
  87. document.getElementById("output").value = output;
  88. }
  89. };
  90. // Send the request with user ID and question
  91. xhr.send("user_input=" + encodeURIComponent(question) + "&session_id=" + encodeURIComponent(userId));
  92. }
  93. // Generate user ID on page load
  94. window.onload = generateUserId;
  95. </script>
  96. </body>
  97. </html> -->
  98. <!DOCTYPE html>
  99. <html lang="en">
  100. <head>
  101. <meta charset="UTF-8">
  102. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  103. <title>Question Form</title>
  104. <style>
  105. body {
  106. font-family: Arial, sans-serif;
  107. margin: 0;
  108. padding: 0;
  109. }
  110. .form-container {
  111. max-width: 400px;
  112. margin: 50px auto;
  113. padding: 20px;
  114. border: 1px solid #ccc;
  115. border-radius: 5px;
  116. }
  117. label {
  118. display: block;
  119. margin-bottom: 8px;
  120. }
  121. input {
  122. width: 100%;
  123. padding: 8px;
  124. margin-bottom: 16px;
  125. box-sizing: border-box;
  126. }
  127. textarea {
  128. width: 100%;
  129. height: 100px;
  130. padding: 8px;
  131. margin-bottom: 16px;
  132. box-sizing: border-box;
  133. }
  134. button {
  135. padding: 8px 16px;
  136. background-color: #3498db;
  137. color: #fff;
  138. border: none;
  139. border-radius: 3px;
  140. cursor: pointer;
  141. }
  142. button:hover {
  143. background-color: #2980b9;
  144. }
  145. .output-container {
  146. margin-top: 20px;
  147. }
  148. </style>
  149. </head>
  150. <body>
  151. <div class="form-container">
  152. <form id="questionForm">
  153. <label for="userId">User ID:</label>
  154. <input type="text" id="userId" required>
  155. <label for="question">Question:</label>
  156. <textarea id="question" required></textarea>
  157. <button type="button" onclick="handleSubmit()">Submit</button>
  158. </form>
  159. <div class="output-container">
  160. <label for="output">Output:</label>
  161. <textarea id="output" readonly></textarea>
  162. </div>
  163. </div>
  164. <script>
  165. function handleSubmit() {
  166. // Get values from the form
  167. var userId = document.getElementById("userId").value;
  168. var question = document.getElementById("question").value;
  169. // Make an AJAX request to the server
  170. var xhr = new XMLHttpRequest();
  171. xhr.open("POST", "/user_input", true);
  172. xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
  173. xhr.onreadystatechange = function () {
  174. if (xhr.readyState == 4 && xhr.status == 200) {
  175. // Parse the JSON response
  176. var response = JSON.parse(xhr.responseText);
  177. // Update the output textarea with question and answer
  178. var output = "Question: " + question + "\nAnswer: " + response.output;
  179. document.getElementById("output").value = output;
  180. }
  181. };
  182. // Send the request with user ID and question
  183. xhr.send("user_input=" + encodeURIComponent(question) + "&session_id=" + encodeURIComponent(userId));
  184. }
  185. </script>
  186. </body>
  187. </html>