-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver.js
53 lines (42 loc) · 1.5 KB
/
server.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
var express=require('express');
var http=require('http');
var fs=require('fs');
var ejs=require('ejs');
var querystring = require('querystring');
var app=express();
var content = fs.readFileSync('./HTMLPage.ejs', 'utf-8');
var compiled = ejs.compile(content);
var kkk=new Array();
var server=http.createServer(app);
server.listen(52273,function(){
console.log('server running');
})
var gametitle='lk';
app.get('/', function (request, response) {
fs.readFile('HTMLPage.ejs', function (error, data) {
response.send(data.toString());
});
});
app.post('/',function(request,response){
request.on('data',function(chunk){
//console.log(chunk.toString());
var data=querystring.parse(chunk.toString());
response.writeHead(200, {'Content-Type':'text/html'});
exports.game_title = function(){
return chunk.toString();
}
var main=require('./main');
});
});
app.get('/result',function(request,response){
// var data=
var main=require('./main');
var game_title=main.games_title();
var game_price=main.games_price();
var youtubeURL=main.youtubeURL();
var youtubeTitle=main.youtubeTitle();
fs.readFile('result.ejs', 'utf8', function (error, data) {
response.writeHead(200, {'Content-Type': 'text/html;charset=UTF-8'});
response.end(ejs.render(data, {title : game_title, price : game_price,youtubeURL: youtubeURL,youtubeTitle: youtubeTitle }));
})
})