Update server.js
Browse files
server.js
CHANGED
@@ -1,13 +1,10 @@
|
|
1 |
const express = require("express");
|
2 |
-
const pretty = require("express-pretty"); // Import express-pretty
|
3 |
const { chromium } = require("playwright-core");
|
4 |
const cheerio = require("cheerio");
|
5 |
|
6 |
const app = express();
|
7 |
const PORT = 7860;
|
8 |
|
9 |
-
app.use(pretty()); // Enable express-pretty
|
10 |
-
|
11 |
async function scrapeMatches() {
|
12 |
const browser = await chromium.launch({
|
13 |
headless: true,
|
@@ -76,7 +73,12 @@ async function scrapeMatches() {
|
|
76 |
app.get("/draw", async (req, res) => {
|
77 |
try {
|
78 |
const matches = await scrapeMatches();
|
79 |
-
|
|
|
|
|
|
|
|
|
|
|
80 |
} catch (error) {
|
81 |
console.error("Error:", error);
|
82 |
res.status(500).json({ success: false, message: "Failed to fetch data" });
|
|
|
1 |
const express = require("express");
|
|
|
2 |
const { chromium } = require("playwright-core");
|
3 |
const cheerio = require("cheerio");
|
4 |
|
5 |
const app = express();
|
6 |
const PORT = 7860;
|
7 |
|
|
|
|
|
8 |
async function scrapeMatches() {
|
9 |
const browser = await chromium.launch({
|
10 |
headless: true,
|
|
|
73 |
app.get("/draw", async (req, res) => {
|
74 |
try {
|
75 |
const matches = await scrapeMatches();
|
76 |
+
const formattedMatches = matches.map(match =>
|
77 |
+
`{\n "homeTeam": "${match.homeTeam}",\n "awayTeam": "${match.awayTeam}",\n "stake": "${match.stake}",\n "prediction": "${match.prediction}",\n "score": "${match.score}"\n}`
|
78 |
+
).join("\n\n");
|
79 |
+
|
80 |
+
res.setHeader("Content-Type", "application/json");
|
81 |
+
res.send(`{\n\n${formattedMatches}\n\n}`);
|
82 |
} catch (error) {
|
83 |
console.error("Error:", error);
|
84 |
res.status(500).json({ success: false, message: "Failed to fetch data" });
|