| <!DOCTYPE html> |
| <html lang="en"> |
| <head> |
| <meta charset="UTF-8"> |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> |
| <title>Register - CodeCraft AI</title> |
| <script src="https://cdn.tailwindcss.com"></script> |
| <script src="https://unpkg.com/feather-icons"></script> |
| <style> |
| .gradient-bg { |
| background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%); |
| } |
| </style> |
| </head> |
| <body class="bg-gray-100 min-h-screen flex items-center justify-center"> |
| <div class="w-full max-w-md p-8 space-y-6 bg-white rounded-xl shadow-lg"> |
| <div class="text-center"> |
| <h1 class="text-3xl font-bold text-gray-900">Create your account</h1> |
| <p class="mt-2 text-gray-600">Join the CodeCraft AI community</p> |
| </div> |
|
|
| <form id="registerForm" class="space-y-6"> |
| <div> |
| <label for="username" class="block text-sm font-medium text-gray-700">Username</label> |
| <input type="text" id="username" name="username" required |
| class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-purple-500 focus:border-purple-500"> |
| </div> |
| <div> |
| <label for="password" class="block text-sm font-medium text-gray-700">Password</label> |
| <input type="password" id="password" name="password" required |
| class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-purple-500 focus:border-purple-500"> |
| </div> |
| <div> |
| <label for="confirmPassword" class="block text-sm font-medium text-gray-700">Confirm Password</label> |
| <input type="password" id="confirmPassword" name="confirmPassword" required |
| class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-purple-500 focus:border-purple-500"> |
| </div> |
| <div> |
| <label for="aiPhrase" class="block text-sm font-medium text-gray-700">Your Secret AI Phrase</label> |
| <p class="text-xs text-gray-500 mb-1">This is a personal phrase you'll use for AI login (e.g., "I am the one who loves pizza and coding")</p> |
| <textarea id="aiPhrase" name="aiPhrase" rows="3" required |
| class="mt-1 block w-full px-3 py-2 border border-gray-300 rounded-md shadow-sm focus:outline-none focus:ring-purple-500 focus:border-purple-500" |
| placeholder="Example: 'I am the one who loves pizza and coding at midnight'"></textarea> |
| </div> |
| <div> |
| <button type="submit" class="w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white gradient-bg hover:opacity-90 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-purple-500"> |
| Create Account |
| </button> |
| </div> |
| </form> |
|
|
| <div class="text-center"> |
| <p class="text-sm text-gray-600"> |
| Already have an account? |
| <a href="login.html" class="font-medium text-purple-600 hover:text-purple-500"> |
| Sign in |
| </a> |
| </p> |
| </div> |
| </div> |
|
|
| <script> |
| feather.replace(); |
| |
| registerForm.addEventListener('submit', async (e) => { |
| e.preventDefault(); |
| |
| const username = document.getElementById('username').value; |
| const password = document.getElementById('password').value; |
| const confirmPassword = document.getElementById('confirmPassword').value; |
| const aiPhrase = document.getElementById('aiPhrase').value; |
| |
| if (password !== confirmPassword) { |
| alert('Passwords do not match'); |
| return; |
| } |
| |
| try { |
| const response = await fetch('/register', { |
| method: 'POST', |
| headers: { |
| 'Content-Type': 'application/json', |
| }, |
| body: JSON.stringify({ |
| username, |
| password, |
| ai_phrase: aiPhrase |
| }), |
| }); |
| |
| const data = await response.json(); |
| if (response.ok) { |
| alert('Registration successful! Please login.'); |
| window.location.href = 'login.html'; |
| } else { |
| alert(data.detail || 'Registration failed'); |
| } |
| } catch (error) { |
| console.error('Error:', error); |
| alert('Registration failed'); |
| } |
| }); |
| </script> |
| </body> |
| </html> |