index.html 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>QbApp Control Panel</title>
  6. <script src="{{ url_for('static', filename='js/jquery-3.7.1.min.js') }}"></script>
  7. </head>
  8. <body>
  9. <h1>Add Magnet Link</h1>
  10. <form id="addMagnetForm" action="/add" method="post">
  11. <input type="text" name="magnet_link" placeholder="Enter magnet link here">
  12. <button type="submit">Add</button>
  13. </form>
  14. <button id="startButton">Start Monitoring</button>
  15. <button id="stopButton">Stop Monitoring</button>
  16. <!-- 加入跳转监控页面的按钮 -->
  17. <a href="/monitor" class="button">Go to Monitor Page</a>
  18. <script>
  19. $(document).ready(function(){
  20. // Handle the form submission
  21. $("#addMagnetForm").on("submit", function(e) {
  22. e.preventDefault(); // Prevent the default form submission
  23. var magnetLink = $(this).find("input[name='magnet_link']").val();
  24. $.ajax({
  25. type: "POST",
  26. url: "/add",
  27. contentType: "application/json",
  28. data: JSON.stringify({ magnet_link: magnetLink }),
  29. success: function(response) {
  30. alert("Magnet link added successfully.");
  31. },
  32. error: function(response) {
  33. alert("Failed to add magnet link.");
  34. }
  35. });
  36. });
  37. $("#startButton").click(function() {
  38. $.ajax({
  39. type: "POST",
  40. url: "/start",
  41. success: function(response) {
  42. alert("Monitoring start successfully.");
  43. },
  44. error: function(response) {
  45. alert("Failed to stop monitoring.");
  46. }
  47. });
  48. });
  49. // Handle the Stop Monitoring button click
  50. $("#stopButton").click(function() {
  51. $.ajax({
  52. type: "POST",
  53. url: "/stop",
  54. success: function(response) {
  55. alert("Monitoring stopped successfully.");
  56. },
  57. error: function(response) {
  58. alert("Failed to stop monitoring.");
  59. }
  60. });
  61. });
  62. });
  63. </script>
  64. </body>
  65. </html>