-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-database.html
More file actions
63 lines (54 loc) · 2.58 KB
/
init-database.html
File metadata and controls
63 lines (54 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
<head>
<title>Initialize Database</title>
<style>
body { font-family: Arial, sans-serif; max-width: 600px; margin: 50px auto; padding: 20px; }
.container { background: #f5f5f5; padding: 30px; border-radius: 10px; }
button { background: #0070f3; color: white; padding: 15px 30px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; }
button:hover { background: #0051cc; }
.result { margin-top: 20px; padding: 15px; border-radius: 5px; }
.success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.error { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
</style>
</head>
<body>
<div class="container">
<h2>Initialize Portfolio Database</h2>
<p>Click the button below to create the messages table in your Neon database:</p>
<label for="url">Vercel App URL:</label>
<input type="text" id="url" placeholder="https://your-app.vercel.app" style="width: 100%; padding: 10px; margin: 10px 0; border: 1px solid #ddd; border-radius: 5px;">
<br><br>
<button onclick="initDatabase()">Initialize Database</button>
<div id="result"></div>
</div>
<script>
async function initDatabase() {
const url = document.getElementById('url').value;
const resultDiv = document.getElementById('result');
if (!url) {
resultDiv.innerHTML = '<div class="error">Please enter your Vercel app URL</div>';
return;
}
try {
resultDiv.innerHTML = '<div>Initializing database...</div>';
const response = await fetch(`${url}/api/init-db`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({ password: 'admin123' })
});
const data = await response.json();
if (response.ok) {
resultDiv.innerHTML = '<div class="success">✅ Database initialized successfully! Your contact form is now ready.</div>';
} else {
resultDiv.innerHTML = `<div class="error">❌ Error: ${data.error}</div>`;
}
} catch (error) {
resultDiv.innerHTML = `<div class="error">❌ Network error: ${error.message}</div>`;
}
}
</script>
</body>
</html>