Toggle navigation
Toggle navigation
This project
Loading...
Sign in
홍용민
/
BusTime
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
이의준
2021-06-02 03:23:45 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
f796a114074e0f005800c467aff05e980ac102f7
f796a114
1 parent
7f31cb3e
Webpage 에서 Server에 POST req 구현
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
75 additions
and
0 deletions
OperatingTest/form.html
OperatingTest/frame.html
OperatingTest/server.txt
OperatingTest/form.html
0 → 100644
View file @
f796a11
<form
action=
"http://34.206.171.225:23023/server"
method=
"post"
>
<!-- method="post"라고 하면 url에 정보가 가려짐, 생략하면 GET임.-->
<input
type=
"text"
name =
"busNumber"
placeholder=
"busNumber"
>
<p><input
type=
"submit"
></p>
</form>
\ No newline at end of file
OperatingTest/frame.html
0 → 100644
View file @
f796a11
<!doctype html>
<!--이 웹페이지가 html로 만들어졌다는 태그-->
<html>
<!--head와 body를 감싸는 태그-->
<head>
<!--본문을 설명하는 태그-->
<title>
webpage frame
</title>
<meta
charset=
"utf-8"
>
</head>
<body>
<!--본문에 해당하는 태그-->
<h1>
webpage frame
</h1>
<ul>
<li>
목차1
</li>
<li>
목차2
</li>
<li>
목차3
</li>
</ul>
<p>
내용 1
</p>
<p>
내용 2
</p>
<!-- target: 새 탭을 여는것-->
<p><a
href =
"https://www.google.com/webhp?hl=ko&sa=X&ved=0ahUKEwjzxPrzkOrwAhWsF6YKHTq_CFwQPAgI"
target =
"_blank"
title =
"하이퍼링크 설명"
>
Go to google
</a></p>
<input
type=
"button"
value=
"BUTTON"
onclick=
"alert('alert box')"
>
<input
type=
"text"
onchange=
"alert('changed')"
>
<br>
<br>
<script>
document
.
write
(
1
+
2
+
3
);
</script>
</body>
</html>
\ No newline at end of file
OperatingTest/server.txt
0 → 100644
View file @
f796a11
// aws 인스턴스 - chatbot /home/ubuntu/server/server.js 파일임.
var http = require('http');
var fs = require('fs');
var url = require('url');
var qs = require('querystring');
var app = http.createServer(function(request,response){
var _url = request.url;
if (_url === '/'){
console.log("url is '/'");
response.writeHead(200);
} else if (_url === '/server'){
console.log(_url);
var body = '';
// post로 전달된 데이터를 담을 변수를 선언
request.on('data', function(data){
// request객체에 on( ) 함수로 'data' 이벤트를 연결
body = body + data;
//data 이벤트가 발생할 때마다 callback을 통해 body 변수에 값을 저장
});
request.on('end', function(){
// request객체에 on( ) 함수로 'end' 이벤트를 연결
var post = qs.parse(body);
// end 이벤트가 발생하면(end는 한번만 발생한다) 3번에서 저장해둔 body 를 querystring 으로 객체화
console.log(post);
// 객체화된 데이터를 로그로 출력
response.writeHead(200, {'Content-Type':'text/html'});
response.end('bus Number = ' + post.busNumber);
// HEADER 와 데이터를 담아서 클라이언트에 응답처리
});
} else {
response.writeHead(404);
response.end('Not found');
}
});
app.listen(23023);
console.log("Listening on 23023");
\ No newline at end of file
Please
register
or
login
to post a comment