Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Ark-Aak committed Jul 23, 2024
1 parent f2b3bc4 commit 5c2f251
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 1 deletion.
22 changes: 22 additions & 0 deletions app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const express = require('express');
const request = require('request');
const app = express();
const port = 8080;

app.use(express.static('public'));

app.get('/data', (req, res) => {
request('https://www.luogu.com.cn/contest/169817?_contentOnly=1', (error, response, body) => {
if (!error && response.statusCode == 200) {
const data = JSON.parse(body);
const participants = data.currentData.contest.totalParticipants;
res.json({ participants: participants });
} else {
res.status(500).send('Error fetching data');
}
});
});

app.listen(port, () => {
console.log(`Server running at http://localhost:${port}/`);
});
20 changes: 19 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,23 @@
"dependencies": {
"express": "^4.19.2",
"request": "^2.88.2"
}
},
"name": "page",
"description": "",
"version": "1.0.0",
"main": "app.js",
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Ark-Aak/server-lmxoi-round2.git"
},
"author": "",
"license": "ISC",
"bugs": {
"url": "https://github.com/Ark-Aak/server-lmxoi-round2/issues"
},
"homepage": "https://github.com/Ark-Aak/server-lmxoi-round2#readme"
}
15 changes: 15 additions & 0 deletions vercel.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"version": 2,
"builds": [
{
"src": "app.js",
"use": "@vercel/node"
}
],
"routes": [
{
"src": "/(.*)",
"dest": "app.js"
}
]
}

0 comments on commit 5c2f251

Please sign in to comment.