김연우

modify read_csv.js

Showing 1 changed file with 52 additions and 43 deletions
const csv = require('csv-parser')
const fs = require('fs')
const results = [];
var choice = "놀거리"
//대분류 선택 과정 필요
exports.chooseFile = function () {
if (choice == "카페") {
fs.createReadStream('cafe_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (choice == "식사") {
fs.createReadStream('meal_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (choice == "놀거리") {
fs.createReadStream('play_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (choice == "술집") {
fs.createReadStream('bar_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
}
//chatbot - reply - app.js
var express = require('express');
const request = require('request');
const TARGET_URL = 'https://api.line.me/v2/bot/message/reply'
const TOKEN = 'MNiReWsDC5DyJeehZ2gHoqlEVjPsno4ScaswBgXNz0lAVW3v2JizZzhF97DPKxe23jduB+YCcBum+KredegXZnxnrovFVt4fEmgeivWgxOzt/AEJ292DZfPn3uW7xrWfBZrlGXDLaL1AMIBlmwSCcwdB04t89/1O/w1cDnyilFU='
const fs = require('fs');
const path = require('path');
const HTTPS = require('https');
const domain = "2021105581.osschatbot2022.tk"
const sslport = 23023;
var first = false; //첫 시도인지
var second = false; //첫번째 분류 선택했는지
......@@ -161,6 +128,45 @@ app.post('/hook', function (req, res) {
}
}
res.sendStatus(200);
chooseFile = function () {
if (destCar == "cafe") {
fs.createReadStream('cafe_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "meal") {
fs.createReadStream('meal_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "play") {
fs.createReadStream('play_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
else if (destCar == "bar") {
fs.createReadStream('bar_list.csv')
.pipe(csv())
.on('data', (data) => results.push(data))
.on('end', () => {
console.log(results);
});
}
}
chooseFile();
});
try {
......@@ -176,4 +182,7 @@ try {
} catch (error) {
console.log('[HTTPS] HTTPS 오류가 발생하였습니다. HTTPS 서버는 실행되지 않습니다.');
console.log(error);
}
\ No newline at end of file
}
const csv = require('csv-parser')
const results = [];
......