forked from Debug-Dreams/FIT-GAME
-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
111 lines (70 loc) · 2.41 KB
/
app.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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
var express = require("express");
var bodyParser = require("body-parser");
// const cv2 = require('opencv4nodejs');
// var NodeWebcam = require( "node-webcam" );
const request = require('request');
const app = express();
app.set('view engine', 'ejs');
app.use(bodyParser.urlencoded({ extended: true }));
app.use(express.static("public"));
const url_endlessRunner_1 = "https://scratch.mit.edu/projects/600560206/embed"
const url_endlessRunner_2 = "https://scratch.mit.edu/projects/599708735/embed"
const url_endlessRunner_3 = "https://scratch.mit.edu/projects/600097774/embed"
var url_send=""
gameName=""
app.get("/", function (req, res) {
res.render("index");
});
app.post("/", function (req, res) {
console.log(req.body);
var play=req.body.play;
if(play=="yes"){
// console.log("hi")
res.redirect("/yoga")
}
})
app.get("/yoga", function (req, res) {
// console.log("hi pt2")
res.render("yoga");
});
app.get("/games", function (req, res) {
res.render("games");
});
app.post("/games", function (req, res) {
console.log(req.body);
var gameName=req.body.gameName;
if(gameName=="endless-runner-1"){
url_send=url_endlessRunner_1;
res.redirect("/play")
}
else if(gameName=="endless-runner-2"){
url_send=url_endlessRunner_2;
res.redirect("/play")
}
else if(gameName=="endless-runner-3"){
url_send=url_endlessRunner_3;
res.redirect("/play")
}
})
app.get("/play", function (req, res) {
// const Vcap = new cv2.VideoCapture(0);
// request('http://localhost:5000/flask', function (error, response, body) {
// console.error('error:', error); // Print the error
// console.log('statusCode:', response && response.statusCode); // Print the response status code if a response was received
// console.log('body:', body); // Print the data received
// // res.send(body); //Display the response on the website
// });
// var Webcam = NodeWebcam.create({});
res.render("play",{gameSrc:url_send});
});
// app.post("/play", function (req, res) {
// console.log(req.body);
// var gameName=req.body.gameName;
// if(gameName=="endless-runner-1"){
// res.redirect("/play");
// }
// })
// host=process.env.PORT
app.listen(process.env.PORT || 3000, function () {
console.log("Server is up and running on port 3000");
});