Toggle navigation
Toggle navigation
This project
Loading...
Sign in
이찬
/
opensource_term_project
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Authored by
이찬
2020-06-15 00:51:50 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
cb1090ea5168f85d4d8a553a3829b3ace8d15d01
cb1090ea
1 parent
f364ba54
프론트와 연결
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
35 additions
and
35 deletions
app.js
app.js
View file @
cb1090e
const
fs
=
require
(
'fs'
)
;
const
port
=
process
.
env
.
PORT
||
5000
;
const
http
=
require
(
'http'
);
const
express
=
require
(
'express'
);
const
bodyParser
=
require
(
'body-parser'
);
const
path
=
require
(
'path'
);
const
fs
=
require
(
'fs'
);
// 파일 읽기, 쓰기 등 을 할 수 있는 모듈
const
app
=
express
();
const
port
=
process
.
env
.
PORT
||
5000
;
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
extended
:
true
}));
const
data
=
fs
.
readFileSync
(
'./database.json'
);
const
conf
=
JSON
.
parse
(
data
);
const
mysql
=
require
(
'mysql'
);
app
.
use
(
'/js'
,
express
.
static
(
__dirname
+
'/js'
));
app
.
use
(
'/css'
,
express
.
static
(
__dirname
+
'/css'
));
app
.
use
(
'/html'
,
express
.
static
(
__dirname
+
'/html'
));
app
.
use
(
'/img'
,
express
.
static
(
__dirname
+
'/img'
));
const
connection
=
mysql
.
createConnection
({
...
...
@@ -38,24 +29,33 @@ const connection = mysql.createConnection({
connection
.
connect
();
app
.
get
(
'/api/visiter'
,
(
req
,
res
)
=>
{
let
DBdata
=
[];
app
.
get
(
'/'
,
(
req
,
res
)
=>
{
fs
.
readFile
(
path
.
join
(
__dirname
,
'html'
,
'index.html'
),
(
err
,
data
)
=>
{
res
.
writeHead
(
200
,{
'Content-Type'
:
'text/html'
});
res
.
end
(
data
);
})
})
app
.
get
(
'/detail.html'
,
(
req
,
res
)
=>
{
fs
.
readFile
(
path
.
join
(
__dirname
,
'html'
,
'detail.html'
),
(
err
,
data
)
=>
{
res
.
writeHead
(
200
,{
'Content-Type'
:
'text/html'
});
res
.
end
(
data
);
})
})
app
.
get
(
'/statistics.html'
,
(
req
,
res
)
=>
{
/*
connection.query(
'SELECT * FROM visiter'
,
'SELECT * FROM visiter',
(err, rows, fields) => {
res
.
send
(
rows
);
DBdata.push(rows);
}
)
}
);
app
.
listen
(
port
,
()
=>
console
.
log
(
`Listening on port
${
port
}
`
));
)*/
fs
.
readFile
(
path
.
join
(
__dirname
,
'html'
,
'statistics.html'
),
(
err
,
data
)
=>
{
res
.
writeHead
(
200
,{
'Content-Type'
:
'text/html'
});
res
.
end
(
data
);
})
})
app
.
listen
(
port
,
()
=>
console
.
log
(
`Listening on port
${
port
}
`
));
\ No newline at end of file
...
...
Please
register
or
login
to post a comment