|
|
import express from "express"; |
|
|
import fetch from "node-fetch"; |
|
|
|
|
|
const app = express(); |
|
|
const PORT = process.env.PORT || 7860; |
|
|
|
|
|
|
|
|
app.get("/", async (req, res) => { |
|
|
try { |
|
|
const url = |
|
|
"https://docs.google.com/spreadsheets/d/e/2PACX-1vQMORhUByI3JJiqJcKrIuMMFS_VG97aqIfb3qIpclL4s93CHflrtq1yggsWpUKLfIzIjZdwvxxjuw4G/pubhtml?widget=true&headers=false"; |
|
|
|
|
|
const response = await fetch(url); |
|
|
let text = await response.text(); |
|
|
|
|
|
|
|
|
text = text.replace(/<script[^>]*>[\s\S]*?<\/script>/gi, ""); |
|
|
|
|
|
|
|
|
text = text.replace( |
|
|
/<head>/i, |
|
|
`<head><base href="https://docs.google.com/">` |
|
|
); |
|
|
|
|
|
res.set("Content-Type", "text/html; charset=utf-8"); |
|
|
res.send(text); |
|
|
} catch (err) { |
|
|
res.status(500).send("Lỗi khi tải Google Sheet: " + err.message); |
|
|
} |
|
|
}); |
|
|
|
|
|
app.listen(PORT, "0.0.0.0", () => { |
|
|
console.log(`🚀 Server chạy ở http://0.0.0.0:${PORT}`); |
|
|
}); |