aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rwxr-xr-xsrc/html/snake.html10
-rw-r--r--src/server.js5
2 files changed, 15 insertions, 0 deletions
diff --git a/src/html/snake.html b/src/html/snake.html
index a05af59..90dc78d 100755
--- a/src/html/snake.html
+++ b/src/html/snake.html
@@ -202,6 +202,16 @@
function gameOver() {
isGameOver = true;
clearInterval(gameInterval);
+
+ const urlParams = new URLSearchParams(window.location.search);
+ const uid = urlParams.get('uid');
+ const mid = urlParams.get('mid');
+ const cid = urlParams.get('cid');
+ console.log(uid, mid, cid);
+
+ const request = new Request(`/setScore?uid=${uid}&cid=${cid}&mid=${mid}&score=${score}`);
+ console.log(request)
+ fetch(request).then(response => console.log("response"));
}
</script>
</body>
diff --git a/src/server.js b/src/server.js
index 80be952..241f3fc 100644
--- a/src/server.js
+++ b/src/server.js
@@ -1,4 +1,5 @@
const express = require('express');
+const request = require('request');
const port = 80;
@@ -13,6 +14,10 @@ function setUpRoutes(){
server.get('/bread', (req, res) => res.sendFile(__dirname + "/html/bread.html"));
server.get('/essay', (req, res) => res.sendFile(__dirname + "/html/essay.html"));
server.get('/snake', (req, res) => res.sendFile(__dirname + "/html/snake.html"));
+ server.get('/setScore', (req, res) => {
+ request(`http://localhost:8000?${req.url.split("?")[1]}`, function(error, response, body) {
+ });
+ })
server.get('/css/:id', (req, res) => {