testlist.js
1.76 KB
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
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var fs = require('fs');
const PORT = 80;
const xports = require('./test1.js');
const zum = require('./test2.js');
const chosun = require('./test3.js');
const yna = require('./test4.js');
//console.log(xports.xports);
//console.log(zum.zum);
//console.log(chosun.chosun);
//console.log(yna.yna);
app.get('/', function(req, res){
var newslist = '';
var newsobject = xports.xports;
console.log(newsobject[0].url);
for(var i = 0; i < newsobject.length; i++){
newslist = newslist +`
<li>
<div class='item'>
<div class='info'>
<span class='time'>${newsobject[i].datetime}</span>
</div>
<div class='img'>
<a>
<img src = ${newsobject[i].image_url}>
</a>
</div>
<div class='news'>
<a href = ${newsobject[i].url}>
<strong>${newsobject[i].title}</strong>
</a>
<p>
${newsobject[i].summary}
</p>
</div>
</div>
</li>`;
}
var html = `
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>ossswoo.tk</title>
</head>
<body>
<div class = 'main'>
<div class = 'center'>
<div>
${newslist}
</div>
</div>
</div>
</body>
</html>`;
res.send(html);
});
app.listen(PORT, function(){
console.log('Code run in https://localhost:'+PORT);
});