-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
55 lines (49 loc) · 1.52 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const express = require("express")
const bodyParser = require("body-parser")
const app = express()
const fs = require("fs")
app.use(bodyParser.json())
app.use("/", express.static(__dirname + "/public"))
app.get("/", (req, res) => {
res.status(200).sendFile(__dirname + "/index.html")
})
app.get("/student", async (req, res) => {
const id = req.query.id
fs.readFile("./request1.xml", "utf8", async function (err, data) {
const student = data.replace(/{STUNO}/g, id)
res.set("Content-Type", "text/xml")
await fetch("https://suwings.syu.ac.kr/websquare/engine/proworks/callServletService.jsp", {
method: "POST",
headers: {
"content-type": "text/xml; charset=utf-8",
},
body: student,
})
.then((data) => data.text())
.then((data) => res.send(data))
})
})
app.get("/rank", async (req, res) => {
const id = req.query.id
const year = req.query.y
const semester = req.query.s
fs.readFile("./request2.xml", "utf8", async function (err, data) {
const rank = data
.replace(/{STUNO}/g, id)
.replace(/{YY}/g, year)
.replace(/{SHTM_CD}/g, semester)
res.set("Content-Type", "text/xml")
await fetch("https://suwings.syu.ac.kr/websquare/engine/proworks/callServletService.jsp", {
method: "POST",
headers: {
"content-type": "text/xml; charset=utf-8",
},
body: rank,
})
.then((data) => data.text())
.then((data) => res.send(data))
})
})
app.listen(80, () => {
console.log("Server running at http://127.0.0.1")
})