SW0000J

testapp.js의 json list 오류

1 +var express = require('express');
2 +var app = express();
3 +var bodyParser = require('body-parser');
4 +var fs = require('fs');
5 +const PORT = 80;
6 +
7 +const xports = require('./test1.js');
8 +const zum = require('./test2.js');
9 +const chosun = require('./test3.js');
10 +const yna = require('./test4.js');
11 +
12 +//console.log(xports.xports);
13 +//console.log(zum.zum);
14 +//console.log(chosun.chosun);
15 +//console.log(yna.yna);
16 +
17 +app.get('/', function(req, res){
18 +
19 + var newslist = '';
20 + var newsobject = xports.xports;
21 + console.log(newsobject[0].url);
22 + for(var i = 0; i < newsobject.length; i++){
23 + newslist = newslist +`
24 + <li>
25 + <div class='item'>
26 + <div class='info'>
27 + <span class='time'>${newsobject[i].datetime}</span>
28 + </div>
29 + <div class='img'>
30 + <a>
31 + <img src = ${newsobject[i].image_url}>
32 + </a>
33 + </div>
34 + <div class='news'>
35 + <a href = ${newsobject[i].url}>
36 + <strong>${newsobject[i].title}</strong>
37 + </a>
38 + <p>
39 + ${newsobject[i].summary}
40 + </p>
41 + </div>
42 + </div>
43 + </li>`;
44 + }
45 +
46 + var html = `
47 + <!DOCTYPE html>
48 + <html>
49 +
50 + <head>
51 + <meta charset="utf-8">
52 + <title>ossswoo.tk</title>
53 + </head>
54 +
55 + <body>
56 + <div class = 'main'>
57 + <div class = 'center'>
58 + <div>
59 + ${newslist}
60 + </div>
61 + </div>
62 + </div>
63 + </body>
64 + </html>`;
65 + res.send(html);
66 +});
67 +
68 +app.listen(PORT, function(){
69 + console.log('Code run in https://localhost:'+PORT);
70 +});
...\ No newline at end of file ...\ No newline at end of file