Spaces:
Sleeping
Sleeping
Download templates/admin_login.html from fromnowoncoding/eventinvite: direct link, hf CLI and curl.
- Browser
- Download file 3.23 kB
-
https://huggingface.co/spaces/fromnowoncoding/eventinvite/resolve/main/templates/admin_login.html
- Command line
-
hf download hf://spaces/fromnowoncoding/eventinvite/templates/admin_login.html
-
curl -L -o admin_login.html https://huggingface.co/spaces/fromnowoncoding/eventinvite/resolve/main/templates/admin_login.html
3.23 kB
| <html lang="zh-TW"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>管理者登入</title> | |
| <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css" rel="stylesheet"> | |
| <link href="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.css" rel="stylesheet"> | |
| </head> | |
| <body> | |
| <div class="container mt-5"> | |
| <div class="row justify-content-center"> | |
| <div class="col-md-6"> | |
| <div class="card"> | |
| <div class="card-header"> | |
| <h3 class="text-center">管理者登入</h3> | |
| </div> | |
| <div class="card-body"> | |
| <form id="loginForm"> | |
| <div class="mb-3"> | |
| <label for="password" class="form-label">密碼</label> | |
| <input type="password" class="form-control" id="password" required> | |
| </div> | |
| <div class="d-grid gap-2"> | |
| <button type="submit" class="btn btn-primary">登入</button> | |
| <a href="/" class="btn btn-secondary">返回首頁</a> | |
| </div> | |
| </form> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| </div> | |
| <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/js/bootstrap.bundle.min.js"></script> | |
| <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11.0.19/dist/sweetalert2.min.js"></script> | |
| <script> | |
| document.getElementById('loginForm').addEventListener('submit', async (e) => { | |
| e.preventDefault(); | |
| const password = document.getElementById('password').value; | |
| try { | |
| const response = await fetch('/api/admin/login', { | |
| method: 'POST', | |
| headers: { | |
| 'Content-Type': 'application/json', | |
| }, | |
| body: JSON.stringify({ password }) | |
| }); | |
| const data = await response.json(); | |
| if (data.success) { | |
| Swal.fire({ | |
| icon: 'success', | |
| title: '登入成功!', | |
| text: '即將進入管理頁面...', | |
| timer: 1500, | |
| showConfirmButton: false | |
| }).then(() => { | |
| window.location.replace('/admin'); | |
| }); | |
| } else { | |
| Swal.fire({ | |
| icon: 'error', | |
| title: '登入失敗', | |
| text: data.error || '密碼錯誤' | |
| }); | |
| } | |
| } catch (error) { | |
| console.error('Login error:', error); | |
| Swal.fire({ | |
| icon: 'error', | |
| title: '登入失敗', | |
| text: '系統錯誤,請稍後再試' | |
| }); | |
| } | |
| }); | |
| </script> | |
| </body> | |
| </html> | |