Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
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 |
Tags
- ๋น๋๊ธฐ
- mysql
- Import
- eport
- object
- sql
- async
- ๋๊ธฐ
- db
- ํผํ
- ๊ฒ์
- prj
- webpack
- JS #ํ๋ก์ ํธ
- addEventListener
- ajax
- execCommand
- callback
- database
- Project
- Porject
- json
- slow and steady
- ์ฐธ๊ณ ๋ธ๋ก๊ทธ
- https://youtube.com/playlist?list=PLuHgQVnccGMA5836CvWfieEQy0T0ov6Jh&si=FTaYv8m21EhO-A2K
- await
- https://m.blog.naver.com/tt2t2am1118/221010125300
- js
- setTimeout()
- promise
Archives
- Today
- Total
C-log
๐Nodejs : section11 - URL, query string-2 ๋ณธ๋ฌธ
728x90
์ด๋ฒ ์๊ฐ์๋ query string์ ์ด์ฉํด์ ํ ํ๋ฆฟ ๋ฆฌํฐ๋ด๋ก ์นํ์ด์ง์ ๊ตฌ์ฑ์ ์์ฑํ ๊ฒ์ด๋ค. ์ด๋ฒ ์๊ฐ์ ์์ ์ ์ด๋ ค์์ด ์์ด์ ์ฝ๋๋ง ์ฌ๋ ค๋ ๊ฒ์ด๋ค. ํ ํ๋ฆฟ์ผ๋ก HTML์ ์์ฑํ ์ ์๋ ๊ฒ์ ์๊ฐํ๋ฉด์ ์ฝ๋๋ฅผ ์ดํด๋ณด์.
//ํด๋น ๊ธฐ๋ฅ์ด ๋์ํ๋ ์๋ฆฌ๋ฅผ ํ์
ํด์ผํ๋ค
var http = require('http');
var fs = require('fs');
var url = require('url');
var app = http.createServer(function (request, response) {
var _url = request.url;
var queryData = url.parse(_url, true).query;
var title = queryData.id;
console.log(queryData.id)
if (_url == '/') {
// _url = '/index.html';
title = 'Welcome';
}
if (_url == '/favicon.ico') {
return response.writeHead(404);
}
response.writeHead(200);
// console.log(__dirname + url);
var template = `
<!doctype html>
<html>
<head>
<title>WEB1 - ${title}</title>
<meta charset="utf-8">
</head>
<body>
<h1><a href="/">WEB</a></h1>
<ol>
<li><a href="/?id=HTML">HTML</a></li>
<li><a href="/?id=CSS">CSS</a></li>
<li><a href="/?id=JavaScript">JavaScript</a></li>
</ol>
<h2>${title}</h2>
...
<img src="coding.jpg" width="100%">
</p><p style="margin-top:45px;">HTML elements are the building blocks of HTML pages. With HTML constructs, images and other objects, such as interactive forms, may be embedded into the rendered page. It provides a means to create structured documents by denoting structural semantics for text such as headings, paragraphs, lists, links, quotes and other items. HTML elements are delineated by tags, written using angle brackets.
</p>
</body>
</html>
`;
response.end(template);
});
app.listen(3000);
728x90
'๐Nodejs > โกver.0' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
๐Nodejs : section19 - NotFound์ฒ๋ฆฌ์ ํํ์ด์ง ์ ์๊ตฌํ (0) | 2024.01.11 |
---|---|
๐Nodejs : section13 - readFile (0) | 2024.01.09 |
๐Nodejs : section10 - URL, query string (0) | 2024.01.08 |
๐Nodejs : section09 - URL์ ์ดํด (0) | 2024.01.08 |
๐Nodejs : section05 - require๊ณผ createServer (0) | 2024.01.08 |
Comments