-
Notifications
You must be signed in to change notification settings - Fork 20
/
set_api_key.html
89 lines (81 loc) · 2.5 KB
/
set_api_key.html
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>BizyAir - Set API Key</title>
<style>
body {
background-color: #121212;
color: #ffffff;
font-family: Arial, sans-serif;
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
margin: 0;
}
.container {
text-align: center;
}
input[type="password"] {
padding: 10px;
margin: 10px;
border: 2px solid rgb(130, 88, 245);
border-radius: 5px;
background-color: #1e1e1e;
color: #ffffff;
width: 200px;
}
button {
padding: 10px 20px;
border: none;
border-radius: 5px;
background-color: rgb(130, 88, 245);
color: #ffffff;
cursor: pointer;
}
button:hover {
background-color: #0056b3;
}
</style>
<script>
async function setApiKey () {
const apiKey = document.getElementById('apiKey').value;
let endpoint = location.href;
if (endpoint.includes('/bizyair/set-api-key'))
endpoint = endpoint.replace('/bizyair/set-api-key', '/bizyair/set_api_key');
else
endpoint = `${endpoint}/bizyair/set_api_key`;
const response = await fetch(endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/x-www-form-urlencoded'
},
body: `api_key=${encodeURIComponent(apiKey)}`
});
if (response.ok) {
alert('API Key set successfully!');
if (window.opener) {
window.opener.location.reload();
window.close();
}
} else {
alert('Failed to set API Key: ' + await response.text());
}
}
</script>
</head>
<body>
<div class="container">
<h1>Set API Key</h1>
<input type="password" id="apiKey" placeholder="Enter API Key">
<button onclick="setApiKey()">Set API Key</button>
<p>To get your key, visit <a href="https://cloud.siliconflow.cn"
target="_blank">https://cloud.siliconflow.cn</a></p>
</div>
</body>
</html>
</div>
</body>
</html>