http://domain/index.php?id=zz3&a=5&b=2
이렇게 있을때.... 주소 끝 변수의 값을 각각 사용하기 위한 방법입니다.
// 기본 셋팅
PORT = "40000";
HOST = null;
// 환경로드
var sys = require('util'),
http = require('http'),
fs = require('fs'),
url = require('url');
// 시작 알림 로그 출력
console.log('Server running');
// html 로드
fs.readFile('index.html', function (err, data) {
if (err) {
throw err;
}
index = data;
});
// 출력
http.createServer(function(request, response) {
response.writeHeader(200, {"Content-Type": "text/html"});
response.write(index); // html 로드 출력
var html = ""; // 기본값 null 지정
// url 파싱 // 참고: http://japhr.blogspot.com/2010/09/url-parsing-in-nodejs-020021.html
var url_parts = url.parse(request.url, true); // url 파싱
var query = url_parts.query; // 쿼티로드 (ex> { id: 'zz3', a: '1', b: '2' } )
html += "id = " + query.id + "<br>"; // html 출력
html += "a = " + query.a + "<br>"; // html 출력
html += "b = " + query.b + "<br>"; // html 출력
console.log(query); //전체 로그 출력
//테스트
// 테스트끝
response.write(html);
response.end(); //close였으나... 다운현상 때문에 end로 변경
}).listen(PORT);
게시판 목록
프로그램
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 |
|---|---|---|---|---|
| 430 | 19년 전 | 4113 | ||
| 429 | 19년 전 | 3308 | ||
| 428 | 19년 전 | 4134 | ||
| 427 | 19년 전 | 3480 | ||
| 426 | 19년 전 | 3108 | ||
| 425 | 19년 전 | 3411 | ||
| 424 | 19년 전 | 2441 | ||
| 423 | 19년 전 | 2869 | ||
| 422 | 19년 전 | 2356 | ||
| 421 | 19년 전 | 3710 | ||
| 420 | 19년 전 | 4744 | ||
| 419 | 19년 전 | 3806 | ||
| 418 |
|
19년 전 | 1753 | |
| 417 | 19년 전 | 2754 | ||
| 416 | 19년 전 | 2395 | ||
| 415 | 19년 전 | 2610 | ||
| 414 | 19년 전 | 4416 | ||
| 413 |
|
19년 전 | 2606 | |
| 412 | 19년 전 | 3053 | ||
| 411 |
|
19년 전 | 2997 | |
| 410 |
|
19년 전 | 3693 | |
| 409 |
|
19년 전 | 3643 | |
| 408 |
|
19년 전 | 1861 | |
| 407 | 19년 전 | 2235 | ||
| 406 | 19년 전 | 2789 | ||
| 405 | 19년 전 | 2458 | ||
| 404 | 19년 전 | 4311 | ||
| 403 | 19년 전 | 3306 | ||
| 402 |
NeoGenesis
|
19년 전 | 4097 | |
| 401 | 19년 전 | 2611 | ||
| 400 |
|
19년 전 | 2503 | |
| 399 | 19년 전 | 2962 | ||
| 398 | 19년 전 | 2490 | ||
| 397 | 19년 전 | 2788 | ||
| 396 | 19년 전 | 2487 | ||
| 395 | 19년 전 | 3192 | ||
| 394 | 19년 전 | 1733 | ||
| 393 | 19년 전 | 2997 | ||
| 392 | 19년 전 | 2267 | ||
| 391 | 19년 전 | 2182 | ||
| 390 | 19년 전 | 2291 | ||
| 389 | 19년 전 | 2648 | ||
| 388 | 19년 전 | 2187 | ||
| 387 | 19년 전 | 4488 | ||
| 386 |
|
19년 전 | 2694 | |
| 385 |
|
19년 전 | 2494 | |
| 384 | 19년 전 | 3030 | ||
| 383 | 19년 전 | 3061 | ||
| 382 | 19년 전 | 3114 | ||
| 381 |
|
19년 전 | 2638 | |
| 380 |
|
19년 전 | 3026 | |
| 379 | 19년 전 | 2551 | ||
| 378 | 19년 전 | 2213 | ||
| 377 | 19년 전 | 2783 | ||
| 376 | 19년 전 | 2472 | ||
| 375 |
|
19년 전 | 2567 | |
| 374 | 19년 전 | 3823 | ||
| 373 | 19년 전 | 3276 | ||
| 372 | 19년 전 | 4996 | ||
| 371 |
세은아빠2
|
19년 전 | 2420 | |
| 370 | 19년 전 | 4504 | ||
| 369 | 19년 전 | 3109 | ||
| 368 | 19년 전 | 2910 | ||
| 367 | 19년 전 | 3730 | ||
| 366 | 19년 전 | 2661 | ||
| 365 | 19년 전 | 3748 | ||
| 364 | 19년 전 | 4023 | ||
| 363 | 19년 전 | 3450 | ||
| 362 | 19년 전 | 3489 | ||
| 361 | 19년 전 | 4110 | ||
| 360 |
hwatta
|
19년 전 | 2367 | |
| 359 | 19년 전 | 5112 | ||
| 358 | 19년 전 | 3660 | ||
| 357 | 19년 전 | 2608 | ||
| 356 |
sdesign1s
|
20년 전 | 2285 | |
| 355 | 20년 전 | 2760 | ||
| 354 | 20년 전 | 3031 | ||
| 353 | 20년 전 | 2798 | ||
| 352 |
|
20년 전 | 5777 | |
| 351 |
|
20년 전 | 2710 | |
| 350 |
|
20년 전 | 4300 | |
| 349 |
hwatta
|
20년 전 | 2187 | |
| 348 | 20년 전 | 7311 | ||
| 347 | 20년 전 | 2418 | ||
| 346 | 20년 전 | 3509 | ||
| 345 | 20년 전 | 4316 | ||
| 344 | 20년 전 | 2659 | ||
| 343 | 20년 전 | 3925 | ||
| 342 | 20년 전 | 3073 | ||
| 341 | 20년 전 | 4098 | ||
| 340 |
|
20년 전 | 5148 | |
| 339 |
|
20년 전 | 4241 | |
| 338 | 20년 전 | 5882 | ||
| 337 | 20년 전 | 2048 | ||
| 336 |
|
20년 전 | 3329 | |
| 335 |
|
20년 전 | 3545 | |
| 334 |
|
20년 전 | 2938 | |
| 333 |
hwatta
|
20년 전 | 2444 | |
| 332 | 20년 전 | 4658 | ||
| 331 | 20년 전 | 2282 |
댓글 작성
댓글을 작성하시려면 로그인이 필요합니다.
로그인하기