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-06 17:53:15 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
0f196bb3d23b3f3d0eb7b88057358b8e6e8a1391
0f196bb3
1 parent
c50a9565
app,js template 수정
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
7 deletions
app.js
app.js
View file @
0f196bb
...
...
@@ -4,14 +4,39 @@ var url = require('url');
var
app
=
http
.
createServer
(
function
(
request
,
response
)
{
var
_url
=
request
.
url
;
if
(
_url
==
'/'
)
{
_url
=
'/index.html'
;
}
if
(
_url
==
'/favicon.ico'
)
{
return
response
.
writeHead
(
404
);
var
queryData
=
url
.
parse
(
_url
,
true
).
query
;
var
pathname
=
url
.
parse
(
_url
,
true
).
pathname
;
var
title
=
queryData
.
id
;
if
(
pathname
==
'/'
)
{
if
(
queryData
.
id
===
undefined
){
var
title
=
"sibal"
;
fs
.
readFile
(
`
${
queryData
.
id
}
`
,
'utf8'
,
(
err
,
description
)
=>
{
console
.
log
(
0
);
var
template
=
`
<html>
<p>
${
title
}
</p>
<p><a href="/?id=index.html">생성기 페이지</a></p>
<p><a href="/?id=detail.html">자세한 정보 페이지</a></p>
<p><a href="/?id=statistics.html">통계 페이지</a></p>
</html>
`
;
response
.
writeHead
(
200
);
response
.
end
(
template
);
});
}
fs
.
readFile
(
`
${
queryData
.
id
}
`
,
'utf8'
,
(
err
,
description
)
=>
{
var
template
=
`
${
description
}
`
;
response
.
writeHead
(
200
);
response
.
end
(
template
);
});
}
else
{
response
.
writeHead
(
404
);
response
.
end
(
"Not Found"
);
}
response
.
writeHead
(
200
);
response
.
end
(
fs
.
readFileSync
(
__dirname
+
_url
));
});
app
.
listen
(
3000
);
\ No newline at end of file
...
...
Please
register
or
login
to post a comment