기본 콘텐츠로 건너뛰기

node.js 홈페이지 구축

node.js를 이용한 홈페이지 구축을 해보자...

하하 물론 node.js는 얼추 보긴 했는데 
문제는 웹 페이지 제작 능력이 완전 바닥 그냥
깡으로 만들어 봐야겠다 ㅋㅋㅋㅋㅋㅋ 

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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta content="ko" http-equiv="Content-Language" />
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<title>멍개님의 Home Page입니다</title>
<style type="text/css">
.auto-style1 {
    font-size: xx-large;
}
.auto-style2 {
    margin-left: 15px;
}
.auto-style3 {
    border-style: solid;
    border-width: 2px;
}
.auto-style4 {
    margin-left: 100px;
}
</style>
<script>
    alert('멍개의 페이지 오신것을 환영합니다. ㅎㅎ');
</script>
<script>
    $(.auto_style).click(function(){
        alert('asd');
        });
</script>
</head>
<body>
<form method="post">
<p class="auto-style1"><strong><a href="file:///F:/bird%20모음/frog.png">
<img alt="" class="auto-style3" height="57" src="frog_small.png" width="100" /><!-- MSComment="autothumbnail" xthumbnail-orig-image="file:///F:/bird 모음/frog.png" --></a>멍개 
Home                              
</strong><input name="login_id" style="width: 132px; height: 31px" value="id" /> <strong><input name="login_pass" style="width: 132px; height: 31px" type="text" value="password" /></strong>
<strong>
<input class="auto-style2" name="submit1" style="width: 55px" type="submit" value="login" /> </strong>
<input name="submit" type="submit" value="회원가입" /></form>
 </p>
<p>
<input class="auto-style4" name="Button1" style="width: 92px" type="button" value="게시판" /></p>
<form method="post">
</form>
</body>
</html>
cs
`

cs
일단 그냥 웹 페이지를 제작을 해볼려고 한다. 우선 node로 로그인 기능을 넣어보아야 겠다 
머라도 만들어 봐야 실력이 빠르게 늘 것 같다.

 
기본적으로 페이지는 이런식으로 구상을 하려고 한다.

일단은 로그인 기능을 만들어야 겠다
로그인 소스는 어디선가 구해놓은게 있다 으하핳 ㅋㅋㅋㅋ


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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
<!DOCTYPE>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script>
$(document).ready(function(){
    // 삭제
    $('#btn_remove').on('click',function(){
        var ck = new Array();
        $('.ck:checked').each(function(index,item){
            ck.push($(item).val());
        });
        $.ajax({
            url:'/remove',
            type:'GET',
            data:{ck:ck},
            success:function(data){
                alert(data+'삭제');
                $('#btn_list').trigger('click');
            }
        });
    });
    // 수정
    $('#btn_add').on('click',function(){
        var id = $('#id').val();
        var pw = $('#pw').val();
        var name = $('#name').val();
        var age = $('#age').val();
        var gender = $('#gender').val();
        $.ajax({
            url:'/add',
            type:'POST',
            data:{id:id,pw:pw,name:name,age:age,gender:gender},
            success:function(data){
                alert(data+'님 추가');
                $('#btn_list').trigger('click');
            }
        });
    });
    // 추가
    $('#btn_modify').on('click',function(){
        var id = $('#id').val();
        var pw = $('#pw').val();
        var name = $('#name').val();
        var age = $('#age').val();
        var gender = $('#gender').val();
        $.ajax({
            url:'/modifyById',
            type:'POST',
            data:{id:id,pw:pw,name:name,age:age,gender:gender},
            success:function(data){
                alert(data+'님 수정');
                $('#btn_list').trigger('click');
            }
        });
    });
    // 목록
    $('#btn_list').on('click',function(){
        $.ajax({
            url:'/list',
            type:'GET',
            success:function(data){
                $('#list').empty();
                $(data).each(function(index,item){
                    $('#list').append('<tr>');
                    $('#list').append('<td><input type="checkbox" class="ck" value="'+item.id+'"></td>');
                    $('#list').append('<td>'+item.id+'</td>');
                    $('#list').append('<td>'+item.pw+'</td>');
                    $('#list').append('<td>'+item.name+'</td>');
                    $('#list').append('<td>'+item.age+'</td>');
                    $('#list').append('<td>'+item.gender+'</td>');
                    $('#list').append('</tr>');
                });
            }
        });
    });
});
</script>
</head>
<body>
    <table border="1">
        <thead>
            <tr>
                <th>id</th>
                <th>pw</th>
                <th>name</th>
                <th>age</th>
                <th>gender</th>
                <th>추가</th>
                <th>수정</th>
            </tr>
        </thead>
        <tbody>
            <tr>
                <td><input type="text" id="id"></td>
                <td><input type="password" id="pw"></td>
                <td><input type="text" id="name"></td>
                <td><input type="text" id="age"></td>
                <td>
                    <select id="gender">
                        <option value="m"></option>
                        <option value="f"></option>
                    </select>
                </td>
                <td><button id="btn_add">add</button></td>
                <td><button id="btn_modify">modify</button></td>
            </tr>
        </tbody>
    </table>
    <button id="btn_list">회원리스트</button>
    <table border="1">
        <thead>
            <tr>
                <th></th>
                <th>id</th>
                <th>pw</th>
                <th>name</th>
                <th>age</th>
                <th>gender</th>
            </tr>
        </thead>
        <tbody id="list">
        </tbody>
    </table>
    <button id="btn_remove">remove</button>
</body>
</html>
cs
클라이언트 측 소스파일

 
이런게 되어져 있다.

일단 크게잡으면 메인 페이지에서 회원가입을 누르면 이 페이지로 넘어오게 해야겠다.

그전에 회원가입을 했을때 이 데이터가 저장될 DB Table을 만들어야 겠다.

 
DB 테이블은 잘 만들었다.
 
기본적으로 값을 그냥 넣어봤다 

어디선가 주어온 소스 내용에 맞춰서 디비를 만들었다.
DB 생성 끝
회원가입 페이지로 넘어가면 이 DB에서 자료를 꺼냈다 뺐다가 해야겠군..

이 두개의 페이지를 어떤식으로 연결을 시킬것인가.......

 
대충 이런식으로 구성 할 생각....

채팅은 기본적으로 구성은 해뒀고

웹 게임을 제작을 해보고 싶은데 어떤 웹 게임을 만들지..... 
흠...........

로그인 부분만 구현 끝나면 게시판이랑 채팅부분은 금방 구현할거 같은데

웹게임이 문제네

moon_and_james-26 

댓글

이 블로그의 인기 게시물

[node.js] 파일 리더기 만들기 - 사용 모듈 정리, pdf 구조, hwp 구조

pdf -> html 변환 가장 무난하다. 기본적으로 pdf는 htm와 비슷한 형태의 구조를 가지고 있다. 크게 header , body , xref table , trailer 의 구조로 되어있다. pdf는 환경에 상관없이 표현을 하기 위한 목적을 가지고 있는 파일이다. 이런 이유 때문에 무난히 진행이 된 것 같다. pdf2htmlex와 pdftohtmljs라는 모듈을 이용을 했다. var pdftohtml = require ( 'pdftohtmljs' ) ; var converter = new pdftohtml ( 'test.pdf' , "sample.html" ) ; converter . convert ( 'ipad' ) . then ( function ( ) { console . log ( "Success" ) ; } ) . catch ( function ( err ) { console . error ( "Conversion error: " + err ) ; } ) ; 이미지나, text같은 것들이 거의 100%로 변환이 된다. docx -> html 변환 docx파일을 html파일로 변환을 할 때는 style 적용과 한글이 깨지는 문제가 있다. 텍스트들을 전부 잘 읽기는 하는데 스타일 정보를 제대로 가져오지 못하기 때문에 좀 애매하다 - Headings. - Lists. - Customisable mapping from your own docx styles to HTML. For instance, you could convert WarningHeading to h1.warning by providing an appropriate style ...

[알고리즘] snake게임 알고리즘

막무가네로 알고리즘을 공부하면 재미가 없으니 게임을 접목하여 다루어 보도록 하겠습니다. 게임의 대상은 스네이크 게임입니다. 많은 사람들은 어릴 때 뱀게임을 많이 해봤을 것 입니다. 이번에 다뤄볼 주제는 뱀이 움직임을 어떻게 구현을 할지 알아보겠습니다. 뱀은 크게 3가지의 경우가 있습니다 1. 가장 중요한 뱀을 움직이기 2. 음식먹기 이때 뱀은 크기가 늘어나야 합니다. 3. 뱀이 움직이는 정책   - 뱀이 움직이지 못하는 경우는 : 우측방향에서 좌측 방향으로 OR 위에 아래 방향고 같이 180도 반전되는 움직임은 막겠습니다. 순수한 알고리즘을 만드는 과정이기 때문에 음식을 먹었는지 안먹었는지 판단하는 부분은 랜덤으로 판단을 하도록 하겠습니다. def is_eat(): return random.choice([1, 0]) 랜덤으로 1, 0을 반환을 해줍니다. 실제로 게임을 만든다면 해당 함수는 뱀의 머리가 음식의 좌표와 같은지 검사를 해주면 되겠습니다. key_position_map = { 'w': [-1, 0], # up 's': [1, 0], # down 'a': [0, -1], # left 'd': [0, 1] # right } direction = key_position_map.get('d') 다음으로는 키맵핑을 한 오브젝트 입니다. direction은 현재 뱀의 방향을 나타냅니다. snake_body = [[2, 3], [1, 3],[1, 2], [1, 1]] 주인공이 되는 뱀의 좌표들 입니다. while True: key = input() new_direction = key_position_map.get(key) if new_direction and direction_check(direction, new_direction): directi...

[css] css로 프린트 방지하기

웹에서 프린트 제어가 불가능 한 줄 알았는데 프린트 클릭 시  스크립트로 해당 이벤트를 받아올 수 있다. 하지만 스크립트를 사용하는 방법은 브라우저마다 작동을 하지 않을 수 있다. 좀 더 찾아보니 css로 인쇄되는 영역을 제어를 해줄 수 있다.  @media print 를 이용하면 된다. < html > < head > < title > print test page < / title > < style > @media print { . np { display : none ; } } < / style > < / head > < body > < div class = "np" > test < / div > < div > test1 < / div > < div > test1 < / div > < div > test1 < / div > < / body > < / html > 위 코드를 보면 np 클래스를 @media print에 넣어주었다. @media print는 인쇄됐을 때의 스타일을 지정을 해주는 것이다.  위에서는 해당 페이지를 인쇄할 때 p를 display : none으로 가려주었다. @media print를 이용하면 좀 더 멋진 인쇄물을 만들 수 ...