geethareddy commited on
Commit
2160d19
·
verified ·
1 Parent(s): 9d724f8

Create login.html

Browse files
Files changed (1) hide show
  1. templates/login.html +200 -0
templates/login.html ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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>Login - AI Coach</title>
7
+ <style>
8
+ body {
9
+ font-family: 'Roboto', Arial, sans-serif;
10
+ margin: 0;
11
+ padding: 0;
12
+ background: linear-gradient(135deg, #f0f2f5 0%, #e9ecef 100%);
13
+ color: #2d3748;
14
+ line-height: 1.6;
15
+ display: flex;
16
+ justify-content: center;
17
+ align-items: center;
18
+ height: 100vh;
19
+ }
20
+ .login-container {
21
+ background-color: #fff;
22
+ padding: 40px;
23
+ border-radius: 12px;
24
+ box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
25
+ width: 100%;
26
+ max-width: 400px;
27
+ text-align: center;
28
+ }
29
+ h2 {
30
+ color: #1a3c7a;
31
+ font-size: 28px;
32
+ font-weight: 700;
33
+ margin-bottom: 20px;
34
+ }
35
+ .input-group {
36
+ margin-bottom: 20px;
37
+ text-align: left;
38
+ }
39
+ label {
40
+ display: block;
41
+ font-size: 15px;
42
+ font-weight: 500;
43
+ color: #4a5568;
44
+ margin-bottom: 8px;
45
+ }
46
+ input {
47
+ width: 100%;
48
+ padding: 12px;
49
+ border: 2px solid #e2e8f0;
50
+ border-radius: 8px;
51
+ font-size: 15px;
52
+ box-sizing: border-box;
53
+ transition: border-color 0.3s ease, box-shadow 0.3s ease;
54
+ }
55
+ input:focus {
56
+ border-color: #ed8936;
57
+ outline: none;
58
+ box-shadow: 0 0 8px rgba(237, 137, 54, 0.3);
59
+ }
60
+ button {
61
+ width: 100%;
62
+ padding: 12px;
63
+ background: linear-gradient(to right, #f6ad55, #ed8936);
64
+ color: #fff;
65
+ border: none;
66
+ border-radius: 8px;
67
+ cursor: pointer;
68
+ font-size: 16px;
69
+ font-weight: 600;
70
+ transition: transform 0.1s ease, background 0.3s ease;
71
+ }
72
+ button:hover {
73
+ background: linear-gradient(to right, #ed8936, #dd6b20);
74
+ transform: scale(1.02);
75
+ }
76
+ .guest-login {
77
+ background: linear-gradient(to right, #38a169, #48bb78);
78
+ margin-top: 15px;
79
+ }
80
+ .guest-login:hover {
81
+ background: linear-gradient(to right, #2f855a, #38a169);
82
+ }
83
+ .signup-link {
84
+ margin-top: 20px;
85
+ font-size: 14px;
86
+ color: #4a5568;
87
+ }
88
+ .signup-link a {
89
+ color: #ed8936;
90
+ text-decoration: none;
91
+ font-weight: 500;
92
+ }
93
+ .signup-link a:hover {
94
+ text-decoration: underline;
95
+ }
96
+ .error-message {
97
+ color: #f56565;
98
+ font-size: 14px;
99
+ margin-top: 10px;
100
+ display: none;
101
+ }
102
+ .error-message.visible {
103
+ display: block;
104
+ }
105
+ @media (max-width: 500px) {
106
+ .login-container {
107
+ padding: 20px;
108
+ margin: 20px;
109
+ }
110
+ h2 {
111
+ font-size: 24px;
112
+ }
113
+ input, button {
114
+ font-size: 14px;
115
+ padding: 10px;
116
+ }
117
+ }
118
+ </style>
119
+ <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@400;500;700&display=swap" rel="stylesheet">
120
+ </head>
121
+ <body>
122
+ <div class="login-container">
123
+ <h2>AI Coach Login</h2>
124
+ <div class="input-group">
125
+ <label for="username">Username</label>
126
+ <input type="text" id="username" placeholder="Enter your username">
127
+ </div>
128
+ <div class="input-group">
129
+ <label for="password">Password</label>
130
+ <input type="password" id="password" placeholder="Enter your password">
131
+ </div>
132
+ <button onclick="login()">Login</button>
133
+ <button class="guest-login" onclick="guestLogin()">Login as Guest</button>
134
+ <p id="error-message" class="error-message"></p>
135
+ <p class="signup-link">Don't have an account? <a href="/signup">Sign up here</a></p>
136
+ </div>
137
+
138
+ <script>
139
+ async function login() {
140
+ const username = document.getElementById('username').value.trim();
141
+ const password = document.getElementById('password').value.trim();
142
+ const errorMessage = document.getElementById('error-message');
143
+
144
+ if (!username || !password) {
145
+ errorMessage.textContent = 'Please enter both username and password.';
146
+ errorMessage.classList.add('visible');
147
+ return;
148
+ }
149
+
150
+ try {
151
+ const response = await fetch('/login', {
152
+ method: 'POST',
153
+ headers: { 'Content-Type': 'application/json' },
154
+ body: JSON.stringify({ username, password })
155
+ });
156
+ const result = await response.json();
157
+
158
+ if (result.status === 'success') {
159
+ window.location.href = '/';
160
+ } else {
161
+ errorMessage.textContent = result.message || 'Login failed. Please try again.';
162
+ errorMessage.classList.add('visible');
163
+ }
164
+ } catch (error) {
165
+ errorMessage.textContent = 'Error during login: ' + error.message;
166
+ errorMessage.classList.add('visible');
167
+ }
168
+ }
169
+
170
+ async function guestLogin() {
171
+ try {
172
+ const response = await fetch('/login', {
173
+ method: 'POST',
174
+ headers: { 'Content-Type': 'application/json' },
175
+ body: JSON.stringify({ username: 'GUEST', password: '' })
176
+ });
177
+ const result = await response.json();
178
+
179
+ if (result.status === 'success') {
180
+ window.location.href = '/';
181
+ } else {
182
+ const errorMessage = document.getElementById('error-message');
183
+ errorMessage.textContent = 'Guest login failed. Please try again.';
184
+ errorMessage.classList.add('visible');
185
+ }
186
+ } catch (error) {
187
+ const errorMessage = document.getElementById('error-message');
188
+ errorMessage.textContent = 'Error during guest login: ' + error.message;
189
+ errorMessage.classList.add('visible');
190
+ }
191
+ }
192
+
193
+ document.getElementById('password').addEventListener('keypress', (e) => {
194
+ if (e.key === 'Enter') {
195
+ login();
196
+ }
197
+ });
198
+ </script>
199
+ </body>
200
+ </html>