http_access.html 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479
  1. {% extends "admin/base.html" %}
  2. {% block content %}
  3. <div class="bg-white rounded-lg shadow-lg p-4 sm:p-6">
  4. <div class="flex justify-between items-center mb-4 sm:mb-6">
  5. <div>
  6. <h2 class="text-xl sm:text-2xl font-bold text-gray-800">Reglas de Acceso HTTP</h2>
  7. <p class="text-sm text-gray-600 mt-1">Las reglas se evalúan en orden. La primera coincidencia determina el acceso.</p>
  8. </div>
  9. <button onclick="showAddModal()" class="bg-blue-600 hover:bg-blue-700 text-white font-semibold px-4 py-2 rounded-lg shadow-md transition-colors">
  10. <i class="fas fa-plus mr-2"></i>Agregar Regla
  11. </button>
  12. </div>
  13. <!-- RC -->
  14. <div class="mb-6 bg-red-50 border-2 border-red-300 rounded-lg p-6 flex items-start space-x-4">
  15. <i class="fas fa-exclamation-triangle text-red-600 text-3xl mt-1 animate-pulse"></i>
  16. <div class="flex-1">
  17. <p class="font-bold text-red-800 text-lg">¡MUY IMPORTANTE!</p>
  18. <p class="text-red-700 mt-2 font-medium">
  19. Esta funcionalidad se encuentra en <strong>RC</strong>. Puede contener errores y comportamientos inesperados.
  20. </p>
  21. <p class="text-red-700 mt-2">
  22. <strong>Por favor, no la uses en producción de momento. Úsala únicamente en un entorno de prueba.</strong>
  23. </p>
  24. </div>
  25. </div>
  26. {% if rules %}
  27. <div class="mb-4 bg-blue-50 border border-blue-200 rounded-lg p-4">
  28. <div class="flex items-start">
  29. <i class="fas fa-info-circle text-blue-600 mt-1 mr-3"></i>
  30. <div class="text-sm text-gray-700">
  31. <p class="font-semibold text-gray-800 mb-1">Importante sobre el orden:</p>
  32. <ul class="list-disc list-inside space-y-1 ml-2">
  33. <li>Las reglas se procesan de arriba hacia abajo</li>
  34. <li>La primera regla que coincida se aplica (allow o deny)</li>
  35. <li>Si ninguna regla coincide, se aplica el comportamiento contrario a la última regla</li>
  36. <li>Se recomienda terminar con "deny all" para evitar confusión</li>
  37. </ul>
  38. </div>
  39. </div>
  40. </div>
  41. <div class="space-y-2">
  42. {% for rule in rules %}
  43. <div class="flex flex-col sm:flex-row items-start justify-between p-4 bg-gradient-to-r from-gray-50 to-white rounded-lg border border-gray-200 hover:border-gray-300 transition-all gap-3">
  44. <div class="flex items-start space-x-3 flex-1 min-w-0 w-full">
  45. <div class="flex items-center space-x-2 flex-shrink-0">
  46. <span class="text-xs font-mono text-gray-400">#{{ loop.index }}</span>
  47. {% if rule.action == 'allow' %}
  48. <span class="inline-flex px-3 py-1 text-xs font-bold rounded-full bg-green-100 text-green-800 border border-green-300">
  49. <i class="fas fa-check mr-1"></i>ALLOW
  50. </span>
  51. {% else %}
  52. <span class="inline-flex px-3 py-1 text-xs font-bold rounded-full bg-red-100 text-red-800 border border-red-300">
  53. <i class="fas fa-times mr-1"></i>DENY
  54. </span>
  55. {% endif %}
  56. </div>
  57. <div class="flex-1 min-w-0">
  58. <div class="flex flex-wrap items-center gap-2">
  59. {% for acl in rule.acls %}
  60. {% if acl.startswith('!') %}
  61. <span class="inline-flex items-center px-2 py-1 rounded bg-orange-100 text-orange-800 text-xs font-mono border border-orange-300">
  62. <i class="fas fa-exclamation-circle mr-1"></i>{{ acl }}
  63. </span>
  64. {% elif acl in ['localhost', 'manager', 'all'] %}
  65. <span class="inline-flex items-center px-2 py-1 rounded bg-purple-100 text-purple-800 text-xs font-mono border border-purple-300">
  66. <i class="fas fa-star mr-1"></i>{{ acl }}
  67. </span>
  68. {% elif 'ports' in acl.lower() %}
  69. <span class="inline-flex items-center px-2 py-1 rounded bg-blue-100 text-blue-800 text-xs font-mono border border-blue-300">
  70. <i class="fas fa-plug mr-1"></i>{{ acl }}
  71. </span>
  72. {% elif acl == 'CONNECT' %}
  73. <span class="inline-flex items-center px-2 py-1 rounded bg-indigo-100 text-indigo-800 text-xs font-mono border border-indigo-300">
  74. <i class="fas fa-link mr-1"></i>{{ acl }}
  75. </span>
  76. {% else %}
  77. <span class="inline-flex items-center px-2 py-1 rounded bg-gray-100 text-gray-800 text-xs font-mono border border-gray-300">
  78. {{ acl }}
  79. </span>
  80. {% endif %}
  81. {% endfor %}
  82. </div>
  83. {% if rule.description %}
  84. <p class="text-xs text-gray-500 mt-2 italic">
  85. <i class="fas fa-comment-alt mr-1"></i>{{ rule.description }}
  86. </p>
  87. {% endif %}
  88. {% if rule.is_negative %}
  89. <p class="text-xs text-orange-600 mt-1">
  90. <i class="fas fa-info-circle mr-1"></i>Contiene negación (!) - se aplica cuando NO coincide con la ACL
  91. </p>
  92. {% endif %}
  93. </div>
  94. </div>
  95. <div class="flex space-x-2 flex-shrink-0 sm:ml-3">
  96. <button onclick='moveRuleUp({{ loop.index0 }})'
  97. class="text-gray-600 hover:text-gray-900 p-2 hover:bg-gray-100 rounded"
  98. title="Mover arriba"
  99. {% if loop.first %}disabled class="opacity-30 cursor-not-allowed"{% endif %}>
  100. <i class="fas fa-arrow-up"></i>
  101. </button>
  102. <button onclick='moveRuleDown({{ loop.index0 }})'
  103. class="text-gray-600 hover:text-gray-900 p-2 hover:bg-gray-100 rounded"
  104. title="Mover abajo"
  105. {% if loop.last %}disabled class="opacity-30 cursor-not-allowed"{% endif %}>
  106. <i class="fas fa-arrow-down"></i>
  107. </button>
  108. <button onclick='editRule({{ loop.index0 }}, "{{ rule.action }}", "{{ rule.acl_string }}", "{{ rule.description }}")'
  109. class="text-blue-600 hover:text-blue-900 p-2 hover:bg-blue-100 rounded"
  110. title="Editar">
  111. <i class="fas fa-edit"></i>
  112. </button>
  113. <button onclick='deleteRule({{ loop.index0 }}, "{{ rule.action }} {{ rule.acl_string }}")'
  114. class="text-red-600 hover:text-red-900 p-2 hover:bg-red-100 rounded"
  115. title="Eliminar">
  116. <i class="fas fa-trash"></i>
  117. </button>
  118. </div>
  119. </div>
  120. {% endfor %}
  121. </div>
  122. {% else %}
  123. <div class="text-center py-12 bg-gray-50 rounded-lg border-2 border-dashed border-gray-300">
  124. <i class="fas fa-shield-alt text-6xl text-gray-300 mb-4"></i>
  125. <p class="text-gray-500 text-lg font-medium">No hay reglas HTTP access configuradas</p>
  126. <p class="text-gray-400 text-sm mt-2">⚠️ Sin reglas, el acceso será DENEGADO por defecto</p>
  127. <div class="mt-4 bg-blue-50 border border-blue-200 rounded-lg p-4 max-w-md mx-auto">
  128. <div class="flex items-start">
  129. <i class="fas fa-info-circle text-blue-600 mt-1 mr-3"></i>
  130. <div class="text-left text-sm">
  131. <p class="font-semibold text-blue-900 mb-1">¿Ya tienes reglas configuradas?</p>
  132. <p class="text-blue-800 mb-2">Si tu squid.conf aún no está dividido, puedes <a href="{{ url_for('admin.split_config') }}" class="underline hover:text-blue-600 font-semibold">dividir tu configuración</a> para una mejor gestión modular.</p>
  133. <p class="text-blue-800">Si ya está dividido, verifica que los archivos estén en el directorio correcto o edítalos directamente desde <a href="{{ url_for('admin.view_config') }}" class="underline hover:text-blue-600 font-semibold">Configuración</a>.</p>
  134. </div>
  135. </div>
  136. </div>
  137. <button onclick="showAddModal()" class="mt-4 bg-blue-600 hover:bg-blue-700 text-white font-semibold px-6 py-2 rounded-lg shadow-md transition-colors">
  138. <i class="fas fa-plus mr-2"></i>Crear primera regla
  139. </button>
  140. </div>
  141. {% endif %}
  142. </div>
  143. <!-- Add Modal -->
  144. <div id="addModal" class="hidden fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4">
  145. <div class="bg-white rounded-lg shadow-xl max-w-2xl w-full p-6 max-h-[90vh] overflow-y-auto">
  146. <h3 class="text-2xl font-bold text-gray-800 mb-4">
  147. <i class="fas fa-plus-circle text-blue-600 mr-2"></i>Agregar Regla HTTP Access
  148. </h3>
  149. <form id="addForm" method="POST" action="/admin/http-access/add">
  150. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  151. <div class="mb-4">
  152. <label class="block text-gray-700 font-semibold mb-2">Acción:</label>
  153. <div class="grid grid-cols-2 gap-3">
  154. <label class="flex items-center justify-center p-4 border-2 border-gray-300 rounded-lg cursor-pointer hover:border-green-500 hover:bg-green-50 transition-all">
  155. <input type="radio" name="action" value="allow" class="mr-3 w-4 h-4" required>
  156. <div class="text-center">
  157. <i class="fas fa-check-circle text-green-600 text-2xl mb-1"></i>
  158. <p class="font-semibold text-gray-800">ALLOW</p>
  159. <p class="text-xs text-gray-600">Permitir acceso</p>
  160. </div>
  161. </label>
  162. <label class="flex items-center justify-center p-4 border-2 border-gray-300 rounded-lg cursor-pointer hover:border-red-500 hover:bg-red-50 transition-all">
  163. <input type="radio" name="action" value="deny" class="mr-3 w-4 h-4" required>
  164. <div class="text-center">
  165. <i class="fas fa-times-circle text-red-600 text-2xl mb-1"></i>
  166. <p class="font-semibold text-gray-800">DENY</p>
  167. <p class="text-xs text-gray-600">Denegar acceso</p>
  168. </div>
  169. </label>
  170. </div>
  171. </div>
  172. <div class="mb-4">
  173. <label class="block text-gray-700 font-semibold mb-2">ACLs:</label>
  174. <div id="addAclsList" class="space-y-2 mb-2">
  175. <!-- ACLs se agregarán dinámicamente -->
  176. </div>
  177. <button type="button" onclick="addAclInput('add')" class="text-blue-600 hover:text-blue-800 text-sm font-medium">
  178. <i class="fas fa-plus-circle mr-1"></i>Agregar ACL
  179. </button>
  180. </div>
  181. <div class="mb-4">
  182. <label class="block text-gray-700 font-semibold mb-2">
  183. <i class="fas fa-star text-yellow-500 mr-1"></i>ACLs Comunes (opcional):
  184. </label>
  185. <div class="grid grid-cols-2 sm:grid-cols-3 gap-2">
  186. <button type="button" onclick="addCommonAcl('add', 'localhost')" class="px-3 py-2 bg-purple-100 hover:bg-purple-200 text-purple-800 rounded text-sm border border-purple-300">
  187. localhost
  188. </button>
  189. <button type="button" onclick="addCommonAcl('add', 'manager')" class="px-3 py-2 bg-purple-100 hover:bg-purple-200 text-purple-800 rounded text-sm border border-purple-300">
  190. manager
  191. </button>
  192. <button type="button" onclick="addCommonAcl('add', 'all')" class="px-3 py-2 bg-purple-100 hover:bg-purple-200 text-purple-800 rounded text-sm border border-purple-300">
  193. all
  194. </button>
  195. <button type="button" onclick="addCommonAcl('add', '!Safe_ports')" class="px-3 py-2 bg-orange-100 hover:bg-orange-200 text-orange-800 rounded text-sm border border-orange-300">
  196. !Safe_ports
  197. </button>
  198. <button type="button" onclick="addCommonAcl('add', '!SSL_ports')" class="px-3 py-2 bg-orange-100 hover:bg-orange-200 text-orange-800 rounded text-sm border border-orange-300">
  199. !SSL_ports
  200. </button>
  201. <button type="button" onclick="addCommonAcl('add', 'CONNECT')" class="px-3 py-2 bg-indigo-100 hover:bg-indigo-200 text-indigo-800 rounded text-sm border border-indigo-300">
  202. CONNECT
  203. </button>
  204. </div>
  205. <p class="text-xs text-gray-500 mt-2">
  206. <i class="fas fa-info-circle mr-1"></i>Haz clic en estas ACLs predefinidas para agregarlas rápidamente
  207. </p>
  208. </div>
  209. <div class="mb-4 bg-yellow-50 border border-yellow-200 rounded-lg p-3">
  210. <p class="text-sm text-gray-700">
  211. <i class="fas fa-lightbulb text-yellow-600 mr-2"></i>
  212. <strong>Tip:</strong> Usa <code class="bg-white px-1 rounded">!</code> antes del nombre de una ACL para negación.
  213. Ej: <code class="bg-white px-1 rounded">!Safe_ports</code> coincide cuando NO es un puerto seguro.
  214. </p>
  215. </div>
  216. <div class="mb-4">
  217. <label class="block text-gray-700 font-semibold mb-2">Descripción (opcional):</label>
  218. <input type="text" name="description" placeholder="Ej: Permitir acceso desde la red local"
  219. class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm">
  220. <p class="text-xs text-gray-500 mt-1">Se agregará como comentario antes de la regla</p>
  221. </div>
  222. <div class="flex space-x-2 justify-end mt-6 pt-4 border-t">
  223. <button type="button" onclick="closeAddModal()" class="px-5 py-2 bg-gray-300 hover:bg-gray-400 text-gray-800 rounded-lg transition-colors font-medium">
  224. Cancelar
  225. </button>
  226. <button type="submit" class="px-5 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium">
  227. <i class="fas fa-save mr-2"></i>Crear Regla
  228. </button>
  229. </div>
  230. </form>
  231. </div>
  232. </div>
  233. <!-- Edit Modal -->
  234. <div id="editModal" class="hidden fixed inset-0 bg-black bg-opacity-50 z-50 flex items-center justify-center p-4">
  235. <div class="bg-white rounded-lg shadow-xl max-w-2xl w-full p-6 max-h-[90vh] overflow-y-auto">
  236. <h3 class="text-2xl font-bold text-gray-800 mb-4">
  237. <i class="fas fa-edit text-blue-600 mr-2"></i>Editar Regla HTTP Access
  238. </h3>
  239. <form id="editForm" method="POST" action="/admin/http-access/edit">
  240. <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
  241. <input type="hidden" name="index" id="editIndex">
  242. <div class="mb-4">
  243. <label class="block text-gray-700 font-semibold mb-2">Acción:</label>
  244. <div class="grid grid-cols-2 gap-3">
  245. <label class="flex items-center justify-center p-4 border-2 border-gray-300 rounded-lg cursor-pointer hover:border-green-500 hover:bg-green-50 transition-all">
  246. <input type="radio" name="action" value="allow" id="editActionAllow" class="mr-3 w-4 h-4" required>
  247. <div class="text-center">
  248. <i class="fas fa-check-circle text-green-600 text-2xl mb-1"></i>
  249. <p class="font-semibold text-gray-800">ALLOW</p>
  250. </div>
  251. </label>
  252. <label class="flex items-center justify-center p-4 border-2 border-gray-300 rounded-lg cursor-pointer hover:border-red-500 hover:bg-red-50 transition-all">
  253. <input type="radio" name="action" value="deny" id="editActionDeny" class="mr-3 w-4 h-4" required>
  254. <div class="text-center">
  255. <i class="fas fa-times-circle text-red-600 text-2xl mb-1"></i>
  256. <p class="font-semibold text-gray-800">DENY</p>
  257. </div>
  258. </label>
  259. </div>
  260. </div>
  261. <div class="mb-4">
  262. <label class="block text-gray-700 font-semibold mb-2">ACLs:</label>
  263. <div id="editAclsList" class="space-y-2 mb-2">
  264. <!-- ACLs se llenarán dinámicamente -->
  265. </div>
  266. <button type="button" onclick="addAclInput('edit')" class="text-blue-600 hover:text-blue-800 text-sm font-medium">
  267. <i class="fas fa-plus-circle mr-1"></i>Agregar ACL
  268. </button>
  269. </div>
  270. <div class="mb-4">
  271. <label class="block text-gray-700 font-semibold mb-2">Descripción (opcional):</label>
  272. <input type="text" name="description" id="editDescription" placeholder="Ej: Permitir acceso desde la red local"
  273. class="w-full px-4 py-2 border border-gray-300 rounded-lg focus:ring-2 focus:ring-blue-500 focus:border-transparent text-sm">
  274. </div>
  275. <div class="flex space-x-2 justify-end mt-6 pt-4 border-t">
  276. <button type="button" onclick="closeEditModal()" class="px-5 py-2 bg-gray-300 hover:bg-gray-400 text-gray-800 rounded-lg transition-colors font-medium">
  277. Cancelar
  278. </button>
  279. <button type="submit" class="px-5 py-2 bg-blue-600 hover:bg-blue-700 text-white rounded-lg transition-colors font-medium">
  280. <i class="fas fa-save mr-2"></i>Guardar Cambios
  281. </button>
  282. </div>
  283. </form>
  284. </div>
  285. </div>
  286. <script>
  287. let addAclCounter = 0;
  288. let editAclCounter = 0;
  289. function showAddModal() {
  290. document.getElementById('addModal').classList.remove('hidden');
  291. document.getElementById('addForm').reset();
  292. document.getElementById('addAclsList').innerHTML = '';
  293. addAclCounter = 0;
  294. // Add one initial ACL input
  295. addAclInput('add');
  296. }
  297. function closeAddModal() {
  298. document.getElementById('addModal').classList.add('hidden');
  299. }
  300. function editRule(index, action, aclString, description) {
  301. document.getElementById('editIndex').value = index;
  302. // Set action radio button
  303. if (action === 'allow') {
  304. document.getElementById('editActionAllow').checked = true;
  305. } else {
  306. document.getElementById('editActionDeny').checked = true;
  307. }
  308. // Set description
  309. document.getElementById('editDescription').value = description || '';
  310. // Parse ACLs and fill inputs
  311. const acls = aclString.split(' ');
  312. const aclsContainer = document.getElementById('editAclsList');
  313. aclsContainer.innerHTML = '';
  314. editAclCounter = 0;
  315. acls.forEach(acl => {
  316. if (acl.trim()) {
  317. addAclInput('edit', acl.trim());
  318. }
  319. });
  320. // If no ACLs were added, add one empty input
  321. if (editAclCounter === 0) {
  322. addAclInput('edit');
  323. }
  324. document.getElementById('editModal').classList.remove('hidden');
  325. }
  326. function closeEditModal() {
  327. document.getElementById('editModal').classList.add('hidden');
  328. }
  329. function addAclInput(mode, value = '') {
  330. const container = document.getElementById(mode + 'AclsList');
  331. const counter = mode === 'add' ? addAclCounter++ : editAclCounter++;
  332. const aclDiv = document.createElement('div');
  333. aclDiv.className = 'flex items-center space-x-2';
  334. aclDiv.id = mode + 'Acl' + counter;
  335. aclDiv.innerHTML = `
  336. <input type="text" name="acls[]" value="${value}" placeholder="Nombre de ACL (ej: localhost, !Safe_ports)"
  337. class="flex-1 px-3 py-2 border border-gray-300 rounded-lg text-sm font-mono focus:ring-2 focus:ring-blue-500" required>
  338. <button type="button" onclick="removeAclInput('${mode}', ${counter})"
  339. class="text-red-600 hover:text-red-800 p-2">
  340. <i class="fas fa-times"></i>
  341. </button>
  342. `;
  343. container.appendChild(aclDiv);
  344. }
  345. function removeAclInput(mode, counter) {
  346. const aclDiv = document.getElementById(mode + 'Acl' + counter);
  347. if (aclDiv) {
  348. // Only allow removal if there's more than one ACL input
  349. const container = document.getElementById(mode + 'AclsList');
  350. if (container.children.length > 1) {
  351. aclDiv.remove();
  352. } else {
  353. alert('Debe haber al menos una ACL en la regla');
  354. }
  355. }
  356. }
  357. function addCommonAcl(mode, aclName) {
  358. addAclInput(mode, aclName);
  359. }
  360. function deleteRule(index, rule) {
  361. if (confirm('¿Estás seguro de que quieres eliminar la regla:\nhttp_access ' + rule + '?\n\nEsto puede afectar el acceso al proxy.')) {
  362. const form = document.createElement('form');
  363. form.method = 'POST';
  364. form.action = '/admin/http-access/delete';
  365. const indexInput = document.createElement('input');
  366. indexInput.type = 'hidden';
  367. indexInput.name = 'index';
  368. indexInput.value = index;
  369. const csrfInput = document.createElement('input');
  370. csrfInput.type = 'hidden';
  371. csrfInput.name = 'csrf_token';
  372. csrfInput.value = '{{ csrf_token() }}';
  373. form.appendChild(indexInput);
  374. form.appendChild(csrfInput);
  375. document.body.appendChild(form);
  376. form.submit();
  377. }
  378. }
  379. function moveRuleUp(index) {
  380. if (index === 0) return;
  381. const form = document.createElement('form');
  382. form.method = 'POST';
  383. form.action = '/admin/http-access/move';
  384. const indexInput = document.createElement('input');
  385. indexInput.type = 'hidden';
  386. indexInput.name = 'index';
  387. indexInput.value = index;
  388. const directionInput = document.createElement('input');
  389. directionInput.type = 'hidden';
  390. directionInput.name = 'direction';
  391. directionInput.value = 'up';
  392. const csrfInput = document.createElement('input');
  393. csrfInput.type = 'hidden';
  394. csrfInput.name = 'csrf_token';
  395. csrfInput.value = '{{ csrf_token() }}';
  396. form.appendChild(indexInput);
  397. form.appendChild(directionInput);
  398. form.appendChild(csrfInput);
  399. document.body.appendChild(form);
  400. form.submit();
  401. }
  402. function moveRuleDown(index) {
  403. const form = document.createElement('form');
  404. form.method = 'POST';
  405. form.action = '/admin/http-access/move';
  406. const indexInput = document.createElement('input');
  407. indexInput.type = 'hidden';
  408. indexInput.name = 'index';
  409. indexInput.value = index;
  410. const directionInput = document.createElement('input');
  411. directionInput.type = 'hidden';
  412. directionInput.name = 'direction';
  413. directionInput.value = 'down';
  414. const csrfInput = document.createElement('input');
  415. csrfInput.type = 'hidden';
  416. csrfInput.name = 'csrf_token';
  417. csrfInput.value = '{{ csrf_token() }}';
  418. form.appendChild(indexInput);
  419. form.appendChild(directionInput);
  420. form.appendChild(csrfInput);
  421. document.body.appendChild(form);
  422. form.submit();
  423. }
  424. </script>
  425. {% endblock %}