Spaces:
Sleeping
Sleeping
Update index.js
Browse files
index.js
CHANGED
|
@@ -4,50 +4,19 @@ const { generateIQC } = require("iqc-canvas");
|
|
| 4 |
const app = express();
|
| 5 |
const PORT = process.env.PORT || 7860;
|
| 6 |
|
| 7 |
-
|
| 8 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
<title>IQC Canvas Generator</title>
|
| 16 |
-
<style>
|
| 17 |
-
body {
|
| 18 |
-
font-family: Arial;
|
| 19 |
-
background: #0f172a;
|
| 20 |
-
color: white;
|
| 21 |
-
text-align: center;
|
| 22 |
-
padding: 40px;
|
| 23 |
-
}
|
| 24 |
-
input, button {
|
| 25 |
-
padding: 10px;
|
| 26 |
-
margin: 10px;
|
| 27 |
-
border-radius: 8px;
|
| 28 |
-
border: none;
|
| 29 |
-
}
|
| 30 |
-
button {
|
| 31 |
-
background: #22c55e;
|
| 32 |
-
color: white;
|
| 33 |
-
cursor: pointer;
|
| 34 |
-
}
|
| 35 |
-
</style>
|
| 36 |
-
</head>
|
| 37 |
-
<body>
|
| 38 |
-
<h1>IQC Canvas Generator</h1>
|
| 39 |
-
<form method="GET">
|
| 40 |
-
<input type="text" name="text" placeholder="Chat Text" required /><br/>
|
| 41 |
-
<input type="text" name="time" placeholder="Time (12.30)" required /><br/>
|
| 42 |
-
<input type="number" name="battery" placeholder="Battery %" value="100"/><br/>
|
| 43 |
-
<button type="submit">Generate</button>
|
| 44 |
-
</form>
|
| 45 |
-
</body>
|
| 46 |
-
</html>
|
| 47 |
-
`);
|
| 48 |
-
}
|
| 49 |
|
| 50 |
-
try {
|
| 51 |
const result = await generateIQC(text, time, {
|
| 52 |
baterai: [true, battery || "100"],
|
| 53 |
operator: true,
|
|
@@ -63,6 +32,156 @@ app.get("/", async (req, res) => {
|
|
| 63 |
}
|
| 64 |
});
|
| 65 |
|
|
|
|
|
|
|
|
|
|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
|
| 9 |
+
/* ============================= */
|
| 10 |
+
app.get("/api", async (req, res) => {
|
| 11 |
+
try {
|
| 12 |
+
const { text, time, battery } = req.query;
|
| 13 |
|
| 14 |
+
if (!text || !time) {
|
| 15 |
+
return res.status(400).json({
|
| 16 |
+
error: 'Gunakan: /api?text=Halo&time=12.30&battery=90'
|
| 17 |
+
});
|
| 18 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
|
|
|
|
| 20 |
const result = await generateIQC(text, time, {
|
| 21 |
baterai: [true, battery || "100"],
|
| 22 |
operator: true,
|
|
|
|
| 32 |
}
|
| 33 |
});
|
| 34 |
|
| 35 |
+
/* ============================= */
|
| 36 |
+
/* UI PREMIUM ROOT / */
|
| 37 |
+
/* ============================= */
|
| 38 |
+
app.get("/", async (req, res) => {
|
| 39 |
+
|
| 40 |
+
res.send(`
|
| 41 |
+
<!DOCTYPE html>
|
| 42 |
+
<html>
|
| 43 |
+
<head>
|
| 44 |
+
<meta charset="UTF-8" />
|
| 45 |
+
<title>IQC Canvas Premium</title>
|
| 46 |
+
|
| 47 |
+
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600;800&display=swap" rel="stylesheet">
|
| 48 |
+
|
| 49 |
+
<style>
|
| 50 |
+
* {
|
| 51 |
+
margin: 0;
|
| 52 |
+
padding: 0;
|
| 53 |
+
box-sizing: border-box;
|
| 54 |
+
font-family: 'Poppins', sans-serif;
|
| 55 |
+
}
|
| 56 |
+
|
| 57 |
+
body {
|
| 58 |
+
min-height: 100vh;
|
| 59 |
+
background: linear-gradient(135deg, #0f0c29, #302b63, #24243e);
|
| 60 |
+
display: flex;
|
| 61 |
+
justify-content: center;
|
| 62 |
+
align-items: center;
|
| 63 |
+
color: white;
|
| 64 |
+
}
|
| 65 |
+
|
| 66 |
+
.container {
|
| 67 |
+
width: 95%;
|
| 68 |
+
max-width: 600px;
|
| 69 |
+
padding: 40px;
|
| 70 |
+
border-radius: 25px;
|
| 71 |
+
backdrop-filter: blur(25px);
|
| 72 |
+
background: rgba(255,255,255,0.05);
|
| 73 |
+
box-shadow: 0 0 60px rgba(0,0,0,0.6);
|
| 74 |
+
text-align: center;
|
| 75 |
+
}
|
| 76 |
+
|
| 77 |
+
h1 {
|
| 78 |
+
font-size: 28px;
|
| 79 |
+
font-weight: 800;
|
| 80 |
+
margin-bottom: 30px;
|
| 81 |
+
background: linear-gradient(90deg,#00f5ff,#7b2ff7);
|
| 82 |
+
-webkit-background-clip: text;
|
| 83 |
+
-webkit-text-fill-color: transparent;
|
| 84 |
+
}
|
| 85 |
+
|
| 86 |
+
input {
|
| 87 |
+
width: 100%;
|
| 88 |
+
padding: 14px;
|
| 89 |
+
margin: 12px 0;
|
| 90 |
+
border-radius: 15px;
|
| 91 |
+
border: none;
|
| 92 |
+
outline: none;
|
| 93 |
+
background: rgba(255,255,255,0.1);
|
| 94 |
+
color: white;
|
| 95 |
+
font-size: 14px;
|
| 96 |
+
}
|
| 97 |
+
|
| 98 |
+
button {
|
| 99 |
+
width: 100%;
|
| 100 |
+
padding: 14px;
|
| 101 |
+
margin-top: 15px;
|
| 102 |
+
border-radius: 15px;
|
| 103 |
+
border: none;
|
| 104 |
+
cursor: pointer;
|
| 105 |
+
font-weight: 600;
|
| 106 |
+
font-size: 15px;
|
| 107 |
+
background: linear-gradient(90deg,#00f5ff,#7b2ff7);
|
| 108 |
+
color: white;
|
| 109 |
+
transition: 0.3s;
|
| 110 |
+
}
|
| 111 |
+
|
| 112 |
+
button:hover {
|
| 113 |
+
transform: scale(1.03);
|
| 114 |
+
box-shadow: 0 0 25px #7b2ff7;
|
| 115 |
+
}
|
| 116 |
+
|
| 117 |
+
.preview {
|
| 118 |
+
margin-top: 30px;
|
| 119 |
+
display: none;
|
| 120 |
+
}
|
| 121 |
+
|
| 122 |
+
.preview img {
|
| 123 |
+
max-width: 100%;
|
| 124 |
+
border-radius: 20px;
|
| 125 |
+
box-shadow: 0 0 40px rgba(0,0,0,0.6);
|
| 126 |
+
}
|
| 127 |
+
|
| 128 |
+
.footer {
|
| 129 |
+
margin-top: 25px;
|
| 130 |
+
font-size: 12px;
|
| 131 |
+
opacity: 0.6;
|
| 132 |
+
}
|
| 133 |
+
</style>
|
| 134 |
+
</head>
|
| 135 |
+
|
| 136 |
+
<body>
|
| 137 |
+
|
| 138 |
+
<div class="container">
|
| 139 |
+
<h1>IQC Canvas Generator</h1>
|
| 140 |
+
|
| 141 |
+
<input type="text" id="text" placeholder="Masukkan text chat..." />
|
| 142 |
+
<input type="text" id="time" placeholder="Waktu (contoh 12.30)" />
|
| 143 |
+
<input type="number" id="battery" placeholder="Battery %" value="100" />
|
| 144 |
+
|
| 145 |
+
<button onclick="generateImage()">Generate Image</button>
|
| 146 |
+
|
| 147 |
+
<div class="preview" id="preview">
|
| 148 |
+
<img id="resultImage"/>
|
| 149 |
+
</div>
|
| 150 |
+
|
| 151 |
+
<div class="footer">
|
| 152 |
+
Premium UI • Auto Preview • Endpoint /iqc
|
| 153 |
+
</div>
|
| 154 |
+
</div>
|
| 155 |
+
|
| 156 |
+
<script>
|
| 157 |
+
async function generateImage() {
|
| 158 |
+
const text = document.getElementById("text").value;
|
| 159 |
+
const time = document.getElementById("time").value;
|
| 160 |
+
const battery = document.getElementById("battery").value;
|
| 161 |
+
|
| 162 |
+
if (!text || !time) {
|
| 163 |
+
alert("Text dan Time wajib diisi!");
|
| 164 |
+
return;
|
| 165 |
+
}
|
| 166 |
+
|
| 167 |
+
const url = "/api?text=" + encodeURIComponent(text)
|
| 168 |
+
+ "&time=" + encodeURIComponent(time)
|
| 169 |
+
+ "&battery=" + encodeURIComponent(battery);
|
| 170 |
+
|
| 171 |
+
const response = await fetch(url);
|
| 172 |
+
const blob = await response.blob();
|
| 173 |
+
const imageUrl = URL.createObjectURL(blob);
|
| 174 |
+
|
| 175 |
+
document.getElementById("resultImage").src = imageUrl;
|
| 176 |
+
document.getElementById("preview").style.display = "block";
|
| 177 |
+
}
|
| 178 |
+
</script>
|
| 179 |
+
|
| 180 |
+
</body>
|
| 181 |
+
</html>
|
| 182 |
+
`);
|
| 183 |
+
});
|
| 184 |
+
|
| 185 |
app.listen(PORT, () => {
|
| 186 |
+
console.log("Server running on port " + PORT);
|
| 187 |
});
|