index.tmpl.html 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. {{ define "index" }}
  2. <!DOCTYPE html>
  3. <html lang="ru">
  4. <head>
  5. <title>WarTank</title>
  6. <meta charset="utf-8">
  7. <meta name="viewport" content="width=device-width, initial-scale=1">
  8. <link href="/static/bootstrap5/css/bootstrap.min.css" rel="stylesheet" crossorigin="anonymous">
  9. <script src="/static/bootstrap5/js/bootstrap.bundle.min.js" crossorigin="anonymous"></script>
  10. <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.11.0/brython.min.js">
  11. </script>
  12. <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/brython@3.11.0/brython_stdlib.js">
  13. </script>
  14. </head>
  15. <body onload="brython({debug:1})">
  16. <h1>WarTank</h1>
  17. <div class="container">
  18. <h2>Список танков</h2>
  19. <div class="btn-group" role="group" aria-label="Управление списком">
  20. <button type="button" id="bot_list_update" class="btn btn-primary">Обновить</button>
  21. <button type="button" id="bot_list_add" class="btn btn-primary">Добавить</button>
  22. </div>
  23. <div class="container" id="bot_list">
  24. </div>
  25. <div class="container" id="bot_list_new">
  26. <!-- Форма для добавления нового бота -->
  27. </div>
  28. </div>
  29. <script type="text/python">
  30. from browser import document, ajax, bind
  31. def bot_list_update(ev):
  32. def read(req):
  33. print(req.text)
  34. document["bot_list"]=req.text
  35. ajax.get("/bot_list/update", oncomplete=read)
  36. def bot_list_add(ev):
  37. print("bot_list_add click!")
  38. botListNew=document["bot_list_new"]
  39. botListNew.clear()
  40. login=document.createElement("span")
  41. login["class"]="badge bg-primary"
  42. login.text="Логин"
  43. botListNew.appendChild(login)
  44. document["bot_list_update"].bind("click", bot_list_update)
  45. document["bot_list_add"].bind("click", bot_list_add)
  46. document.attach("Hello !")
  47. </script>
  48. </body>
  49. </html>
  50. {{ end }}