hono / index.js
semuthitamku's picture
Update index.js
0ab1b6a verified
import { serve } from '@hono/node-server'
import Groq from 'groq-sdk'
import { Hono } from 'hono'
import { logger } from 'hono/logger'
const app = new Hono()
// const cache = new Map()
const client = new Groq()
const systemPrompt = `
Kamu adalah seorang developer frontend ahli.
Buatkan kode HTML untuk sebuah halaman web menggunakan class dari Tailwind CSS.
Pastikan hasilnya terlihat modern dan profesional.
PENTING: Respon kamu harus berisi kode HTML saja.
Jangan sertakan penjelasan, komentar, atau markdown code block.
`.trim()
app.use(logger())
app.get('/fetch', async (c) =>
c.html(await (await fetch(c.req.query('url'))).text())
)
app.get('*', async (c) =>
c.html(
(
await client.chat.completions.create({
messages: [
{ role: 'system', content: systemPrompt },
{ role: 'user', content: `Bikinin HTML buat halaman ${c.req.path}` }
],
model: 'meta-llama/llama-4-maverick-17b-128e-instruct'
})
).choices[0].message.content || 'error'
)
)
const port = process.env.PORT || 7860
console.log('App running on port', port)
serve({ fetch: app.fetch, port })