alfixd/htmlgen
0
1const express = require('express');2const axios = require('axios');3 4const app = express();5const PORT = process.env.PORT || 7860;6 7async function generateHtml(path) {8 const prompt = `Buat halaman portofolio HTML dengan struktur: header (foto placeholder, nama [ALFI SYAHRIAL], profile [https://files.catbox.moe/qowhyl.jpg]), 4 ikon sosmed (LinkedIn [LINK_LN], GitHub [LINK_GH], Instagram [LINK_IG], Twitter [LINK_TW]), section skills (6 badge skill [JAVASCRIPT]-[PYTHON]), section projects (2 card: gambar placeholder, nama [REST-API], deskripsi [DESCRIPTION], link demo [GITHUB], kode [GITHUB]), kontak (email [EMAIL] dengan ikon), footer (copyright 2025 [ALFI SYAHRIAL]). Gunakan Tailwind CSS (CDN) + Font Awesome (CDN), desain responsif 1 kolom (mobile) dan 2 kolom (desktop untuk projects), tanpa JavaScript. Output hanya kode HTML lengkap dari <!doctype> hingga </html> tanpa formatting tambahan, langsung kirim html nya saja tanpa penjelasan tanpa \`\`\`html \`\`\` juga`;9 const url = `https://api.siputzx.my.id/api/ai/gemini-lite?prompt=${encodeURIComponent(prompt)}&model=gemini-2.0-flash-lite`;10 const res = await axios.get(url, { timeout: 30000 });11 return res.data?.data?.parts?.[0]?.text?.trim()?.replace(/^(\`\`\`html)|(\`\`\`)$/g, '') || '<!doctype html><html><body>Error</body></html>';12}13 14app.get('*', async (req, res) => {15 res.type('html');16 res.write(`<!doctype html><html><head><meta charset="utf-8"><title>Loading...</title></head><body><div id="wait" style="font-family:sans-serif;text-align:center;margin-top:50px;font-size:24px">wait...</div>`);17 18 try {19 const html = await generateHtml(req.path);20 res.write(`21 <script>document.getElementById('wait').remove()</script>22 ${html}23 `);24 res.end();25 } catch (error) {26 console.error('Error:', error.message);27 res.end('<b>Terjadi kesalahan server</b></body></html>');28 }29});30 31app.listen(PORT, '0.0.0.0', () => {32 console.log(`Server jalan di http://0.0.0.0:${PORT}`);33});