최예리

분류 생성 기능 완료, home page 정리 필요, 디렉터리 이동 기능 필요

"use strict";
const express = require('express');
const multer = require('multer');
const bodyParser = require('body-parser');
const fs = require('fs');
const PORT = 8080;
const HOST = '0.0.0.0';
const app = express();
const dataFolder = './tensorflow/data';
const testFolder = './tensorflow/test';
app.set('view engine', 'pug');
app.set('views', './views');
app.locals.pretty = true
app.use(bodyParser.urlencoded({extended:false}));
// Redirect Root to Home
app.get('/', (req, res) => {
res.redirect('/home');
});
// Main Page
app.get('/home', (req, res) => {
fs.readdir(dataFolder, function(error, filelist){
if(error)
console.log(error);
res.render('home', {fileList:filelist});
});
});
// Directory existence checking
app.post('/directory_check', (req, res) => {
var dir = req.body.directoryName;
// Directory exists
if(fs.existsSync(dataFolder + '/' + dir))
{
// Go back page
res.sendfile('./views/error_directoryAdd.html');
}
// Directory doesn't exist
else
{
// Make directory
fs.mkdirSync(dataFolder + '/' + dir);
console.log('디렉토리: ' + dir + ' 생성 완료');
res.redirect('/home/' + dir);
}
});
// Basic Directory Page
app.get('/home/:directoryName', (req, res) => {
});
// Image Upload Directory Page
app.get('/home/:directoryName/upload', (req, res) => {
var upload_data = multer({ dest: 'tensorflow/data/' + directoryName });
upload_data.array('ImageData')
var imgFileArr = req.files;
});
// Delete Directory
app.delete('/home/:directoryName', (req, res) => {
});
// Image Test Page
app.post('/test', (req, res) => {
var upload_test = multer({ dest: 'tensorflow/test/' });
upload_test.single('ImageTest')
var imgTest = req.file;
});
app.listen(PORT, HOST);
console.log('Running on http://${HOST}:${POST}');
\ No newline at end of file
doctype html
html
head
meta(charset='utf-8')
title 파일 업로드
body
form(action="upload" method="POST" enctype="multipart/form-data")
input(type="file", name="userfile")
input(type="submit", value="전송")
\ No newline at end of file
<script type="text/javascript">
alert("이미 존재하는 분류입니다.");
history.back();
</script>
doctype html
html
head
meta(charset='utf-8')
title 분류 리스트
body
form(action="directory_check" method="post")
p 새로 만들 분류명:
input(name="directoryName", type="text")
input(type="submit", value="생성")
p
form(action="test" method="post" enctype="multipart/form-data")
p 테스트할 이미지:
input(name="ImageTest", type="file")
input(type="submit", value="테스트")
ul
- var folderList=fileList
each folder in folderList
li=folder
form(action=folder method="get")
input(type="submit", value="편집")
form(action=folder method="delete")
input(type="submit", value="삭제")
\ No newline at end of file