app.js 4.02 KB
var XLSX = require('xlsx');
var express = require('express')
var app = express();
var fs = require('fs');
var http = require('http');


var workbook = XLSX.readFile('data.xlsx');

var firstWsheetName = workbook.SheetNames[0];
var firstWsheet = workbook.Sheets[firstWsheetName];

var lotte = firstWsheet['P2'];
var lg = firstWsheet['P3'];
var sk = firstWsheet['P4'];
var hanhwa = firstWsheet['P5'];
var nc = firstWsheet['P6'];
var doosan = firstWsheet['P7'];
var samsung = firstWsheet['P8'];
var kia = firstWsheet['P9'];
var kiwoom = firstWsheet['P10'];
var kt = firstWsheet['P11'];



app.get('/',function(req,res){
    res.writeHead(200,{"Content-Type":"text/html"});
    fs.createReadStream("./html/index.html").pipe(res);
})

app.get('/info',function(req,res){
    res.writeHead(200,{"Content-Type":"text/html"});
    fs.createReadStream("./html/info.html").pipe(res);
})

app.get('/vs',function(req,res){
    res.writeHead(200,{"Content-Type":"text/html"});
    fs.createReadStream("./html/vs.html").pipe(res);
})



app.get('/vs/lg',function(req,res){
    if(lotte.v>lg.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/lg_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/lg_w.html").pipe(res);
    }
})

app.get('/vs/kia',function(req,res){
    if(lotte.v>kia.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/kia_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/kia_w.html").pipe(res);
    }
})

app.get('/vs/sk',function(req,res){
    if(lotte.v>sk.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/sk_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/sk_w.html").pipe(res);
    }
})

app.get('/vs/hanhwa',function(req,res){
    if(lotte.v>hanhwa.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/hanhwa_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/hanhwa_w.html").pipe(res);
    }
})

app.get('/vs/nc',function(req,res){
    if(lotte.v>nc.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/nc_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/nc_w.html").pipe(res);
    }
})

app.get('/vs/doosan',function(req,res){
    if(lotte.v>doosan.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/doosan_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/doosan_w.html").pipe(res);
    }
})

app.get('/vs/samsung',function(req,res){
    if(lotte.v>samsung.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/samsung_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/samsung_w.html").pipe(res);
    }
})

app.get('/vs/kiwoom',function(req,res){
    if(lotte.v>kia.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/kiwoom_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/kiwoom_w.html").pipe(res);
    }
})

app.get('/vs/kt',function(req,res){
    if(lotte.v>kia.v){
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/kt_l.html").pipe(res);
    }
    else{
        res.writeHead(200,{"Content-Type":"text/html"});
        fs.createReadStream("./html/kt_w.html").pipe(res);
    }
})

var server = app.listen(23023,function(){
    var host = server.address().address
    var port = server.address().port
    console.log("Listening at http://%s:%s",host,port)
})