-
Notifications
You must be signed in to change notification settings - Fork 0
/
giantsApi.js
60 lines (56 loc) · 1.12 KB
/
giantsApi.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
const express = require('express'),
app = express(),
fs = require('fs'),
csvSync = require('csv-parse/lib/sync'),
Pitcher = require('./Pitcher'),
file = './giants_pitchier.csv';
var data = fs.readFileSync(file),
res = csvSync(data),
pitcherarr = [];
//初期化
for (var youso of res) {
pitcherarr.push(
new Pitcher(
youso[0],
youso[1],
youso[2],
youso[3],
youso[4],
youso[5],
youso[6],
youso[7],
youso[8],
youso[9],
youso[10],
youso[11],
youso[12],
youso[13],
youso[14],
youso[15],
youso[16],
youso[17],
youso[18],
youso[19],
youso[20],
youso[21],
youso[22],
youso[23],
youso[24],
youso[25],
youso[26],
youso[27]
)
);
}
// console.log(pitcherarr[0].era);
app.get('/', (req, res) => {
res.render('./index.ejs', {
title: 'Posted',
content: pitcherarr[0].era,
});
});
app.post('/', (req, res) => {
res.header('Content-Type', 'application/json; charset=utf-8');
res.send(`{ "player":${pitcherarr[0].player} }`);
});
app.listen(3000);