김동진

최종1

No preview for this file type
File mode changed
This diff is collapsed. Click to expand it.
......@@ -2,22 +2,24 @@ var template = require('./template.js');
var qs = require('querystring');
var db = require('./db.js');
exports.foodInfo = function(request, response){
var title = '음식 영양정보';
var description = '음식을 검색하면 음식의 칼로리, 탄수화물, 단백질, 지방, 나트륨의 정보를 알려드립니다!';
var title = '식품 영양정보';
var description = '입력한 음식의 영양 정보(칼로리, 단백질, 지방, 탄수화물, 나트륨)를 알려드립니다!';
var html = template.html(title,`
<h2>${title}</h2>
<p>${description}</p>
<div style= "font-size:25px; background-color:#ffffff">
<h2><font color="black">${title}<div style= "font-size:10px;"><br><div style= "font-size:20px;">${description}</font></div></h2>
<form action="/foodInfo_search" method="post">
<input type = 'text' name = 'search' placeholder = '검색어 입력' maxlength = 255 value = "" autocomplete = "off">
<button type = "submit" name = "click">검색</button>
<input type = 'text' name = 'search' placeholder = '검색어 입력' maxlength = 255 value = "" autocomplete = "off" style="width:300px;height:20px;font-size:20px;">
<button type = "submit" name = "click" style="font-size:20px;">검색</button>
</form>
</div>
`);
response.writeHead(200);
response.end(html);
}
function foodTable(foodInfo, list, num){
var tag = '';
tag += `<table`;
tag += `<table style='width:100%;'`;
tag += `
<tr>
<td>이름</td>
......@@ -66,8 +68,8 @@ exports.foodInfo_search = function(request, response){
request.on('end', function(){
var post = qs.parse(body);
db.query(`SELECT * FROM fooddb`, function (error, foodInfo) {
var title = '음식 영양정보';
var description = '음식을 검색하면 음식의 칼로리, 탄수화물, 단백질, 지방, 나트륨의 정보를 알려드립니다!';
var title = '식품 영양정보';
var description = '입력한 음식의 영양 정보(칼로리, 단백질, 지방, 탄수화물, 나트륨)를 알려드립니다!';
var search = post.search; // 검색어
var num = 0; // 검색된 개수
var foodName = '';
......@@ -81,16 +83,16 @@ exports.foodInfo_search = function(request, response){
}
}
var html = template.html(title,`
<h2>${title}</h2>
<p>${description}</p>
<form action="/foodInfo_search" method="post">
<input type = 'text' name = 'search' placeholder = '검색어 입력' maxlength = 255 value = "${search}" autocomplete = "off">
<button type = "submit" name = "click">검색</button>
</form>
<br>
${search}(으)로 검색된 결과 : ${num}
${foodTable(foodInfo, list, num)}
<br><br><br><br>
<div style= "font-size:25px; background-color:#ffffff">
<h2><font color="black">${title}<div style= "font-size:10px;"><br><div style= "font-size:20px;">${description}</font></div></h2>
<form action="/foodInfo_search" method="post">
<input type = 'text' name = 'search' placeholder = '검색어 입력' maxlength = 255 value = "" autocomplete = "off" style="width:300px;height:20px;font-size:20px;">
<button type = "submit" name = "click" style="font-size:20px;">검색</button>
</form>
<p style= "font-size:20px;">${search}(으)로 검색된 결과 : ${num}개</p>
</div>
${foodTable(foodInfo, list, num)}
<br><br>
`);
response.writeHead(200);
response.end(html);
......
var template = require('./template.js');
exports.home = function(request, response){
var title = 'HealthProtector란?';
var title = 'home';
var description = '개개인의 신체 정보에 따라 일일 권장 섭취량을 알려주고, 좋아하는 음식을 검색하면 영양정보를 알려주는 사이트 입니다.';
var html = template.html(title,`
<style>
@import url('https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap');
</style>
<script src="https://use.fontawesome.com/releases/v5.2.0/js/all.js"></script>
<style type="text/css">
div{
text-align:center;
border:0px solid none;
margin:0px 0px 0px 0px;
}
a { text-decoration:none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:focus { text-decoration: none; }
a:hover, a:active { text-decoration: none; }
}
</div>
</style>
<div style= font-size:40px;background-image:url("https://source.unsplash.com/jFCViYFYcus");padding:50px;>
<h1 style=font-family: 'Do Hyeon', sans-serif;><a href="/"><font color="white">HealthProtector</font></a></h1>
<h1 style="font-family: 'Trade Winds', cursive;"><a href="/"><font color="white">Health Protector</font></a></h1>
</div>
<div style= font-size:20px;text-align:left;width: 100%;float:left:>
......@@ -37,24 +16,24 @@ exports.home = function(request, response){
<div style="color : gray";>
<i class="fas fa-calculator fa-3x"></i>
</div>
<h2 style=font-family: 'Do Hyeon', sans-serif;><a href="/countKcal"><font color="black">칼로리 계산</font></a></h2>
<h4 style=font-family: 'Do Hyeon', sans-serif;><font color="gray">나에게 맞는 일일 권장 섭취량(kcal)을 계산해보세요!</font></h4>
<h2><a href="/countKcal"><font color="black">칼로리 계산</font></a></h2>
<h4><font color="gray">나에게 맞는 일일 권장 섭취량(kcal)을 계산해보세요!</font></h4>
</div>
<div style= width:33%;float:right;padding:5px;>
<div style="color : gray";>
<i class="fas fa-book fa-3x"></i>
</div>
<h2 style=font-family: 'Do Hyeon', sans-serif;><a href="/foodInfo"><font color="black">음식별 영양정보</font></a></h2>
<h4 style=font-family: 'Do Hyeon', sans-serif;><font color="gray">음식별 식품 영양정보에 대해 알려드립니다!</font></h4>
<h2><a href="/foodInfo"><font color="black">음식별 영양정보</font></a></h2>
<h4><font color="gray">음식별 식품 영양정보에 대해 알려드립니다!</font></h4>
</div>
<div style= width:33%;float:right;padding:5px;>
<div style="color : gray";>
<i class="fas fa-location-arrow fa-3x"></i>
</div>
<h2 style=font-family: 'Do Hyeon', sans-serif;><a href="/searchGym"><font color="black">헬스장 찾기</font></a></h2>
<h4 style=font-family: 'Do Hyeon', sans-serif;><font color="gray">위치를 입력하면 그 주위의 헬스장을 찾아드립니다!</font></h4>
<h2><a href="/searchGym"><font color="black">헬스장 찾기</font></a></h2>
<h4><font color="gray">위치를 입력하면 그 주위의 헬스장을 찾아드립니다!</font></h4>
</div>
<br><br><br><br><br><br><br><br>
` );
......
var template = require('./template.js');
exports.info = function(request, response){
var title = 'HealthProtector란?';
var description = '개개인의 신체 정보에 따라 일일 권장 섭취량을 알려주고, 좋아하는 음식을 검색하면 영양정보를 알려주는 사이트 입니다.';
var title = 'Health Protector';
var description = `사용자의 신체정보와 목표에 따른 일일 권장 칼로리,
<br>하루동안 섭취한 총칼로리를 계산하고,
<br>헬스장의 위치와 상세정보를 소개하고,
<br>좋아하는 음식의 영양정보를 알려주는,
<br>사용자의 건강 증진을 도모하는 사이트입니다.`;
var html = template.html(title,`
<style>
@import url('https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap');
</style>
<style type="text/css">
div{
text-align:center;
border:0px solid none;
margin:0px 0px 0px 0px;
}
a { text-decoration:none; }
a:visited { text-decoration: none; }
a:hover { text-decoration: none; }
a:focus { text-decoration: none; }
a:hover, a:active { text-decoration: none; }
}
</div>
</style>
<br><br><br>
<div style= font-size:20px; "font-family: 'Do Hyeon', sans-serif;">
<h2>${title}</h2>
<br>
<div style= "font-family: 'Trade Winds', cursive;">
<h1><font color="#213b19">${title}</font></h1>
</div>
<div id="info" style= font-size:20px;>
<hr style= "width : 200px;height:2px;background-color:#213b19">
<h3>${description}</h3>
</div>
<div id= "info" >
<h1><font color="#213b19">Contact</font></h1>
<hr style= "width : 145px;height:2px;background-color:#213b19">
<h4><font color="gray">피드백, 오류 등의 연락은 언제나 환영입니다!</font></h4>
<h3>경희대학교 컴퓨터공학과&emsp;&emsp; &emsp; 경희대학교 컴퓨터공학과</h3>
<h2 style="marin:0px;margin-top: 0px;margin-bottom: 0px;">김동진 &emsp;&emsp;&emsp; &emsp;&emsp;&emsp; &nbsp; 양효빈</h2>
<h3 style= "margin-top: 0px;margin-bottom: 0px;">&nbsp;rlaehdwls310@khu.ac.kr&emsp;&emsp;&emsp;&emsp;qls0786@khu.ac.kr&emsp;</h3>
</div>
` );
response.writeHead(200);
......
......@@ -2,18 +2,15 @@ var template = require('./template.js');
var key = require('./appkey.js');
exports.searchGym = function(request, response){
var title = '헬스장 찾기';
var description = '위치를 입력하면 그 주위의 헬스장을 찾아드립니다!';
var description = '원하는 장소를 입력하면 그 주변의 헬스장 위치 정보를 알려드립니다!';
var html = template.html(title,`
<style>
@import url('https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap');
</style>
<div style= "font-size:25px; background-color:#ffffff">
<h2><font color="black">${title}<br><div style= "font-size:20px;font-family: 'Do Hyeon', sans-serif;">${description}</font></div></h2>
<h2><font color="black">${title}<div style= "font-size:10px;"><br><div style= "font-size:20px;">${description}</font></div></h2>
</div>
<style>
.map_wrap, .map_wrap * {margin:0;padding:0;font-family:'Malgun Gothic',dotum,'돋움',sans-serif;font-size:12px;}
.map_wrap a, .map_wrap a:hover, .map_wrap a:active{color:#000;text-decoration: none;}
.map_wrap {position:relative;width:100%;height:500px;}
.map_wrap {position:relative;width:100%;height:450px;}
#menu_wrap {position:absolute;top:0;left:0;bottom:0;width:250px;margin:10px 0 30px 10px;padding:5px;overflow-y:auto;background:rgba(255, 255, 255, 0.7);z-index: 1;font-size:12px;border-radius: 10px;}
.bg_white {background:#fff;}
#menu_wrap hr {display: block; height: 1px;border: 0; border-top: 2px solid #5F5F5F;margin:3px 0;}
......@@ -289,6 +286,7 @@ exports.searchGym = function(request, response){
}
</script>
<br>
<br>
`);
response.writeHead(200);
response.end(html);
......
<!DOCTYPE html>
<html>
<head>
<title>HelP - ${title}</title>
<meta charset="utf-8" />
</head>
<body>
<style type="text/css">
div{
@import url('https://fonts.googleapis.com/css2?family=Jua&family=Noto+Sans+KR&display=swap');
text-align:center;
border:1px solid none;
margin:0px 0px 0px 0px;
padding:0px;https://source.unsplash.com/random/1920x1080;
}
a { text-decoration:none }
}
</div>
</style>
<div style="font-family:'Jua',sans-serif";>
<h3 style=width:180px;float:left;><a href="/"><font color="black">HealthProtector</font></a></h3>
<h3 style=width:120px;float:left;><a href="/countKcal"><font color="black">칼로리 계산</a></h3>
<h3 style=width:120px;float:left;><a href="/foodInfo"><font color="black">식품 영양정보</a></h3>
<h3 style=width:150px;float:right;><a href="/"><font color="black";text-align="right">만든 사람</a></h3>
</div>
<br><br><br><br>
${body}
<div style= width:100%;font-size:9px;position:fixed;bottom:0;float:left;padding:0px;background-color:#a3a19e;>
<h4><font color="white">Copyright(C) HealThProtector 2020</h4>
</div>
</body>
</html>
\ No newline at end of file
......@@ -4,10 +4,12 @@ module.exports = {
<!DOCTYPE html>
<html>
<head>
<title>HelP - ${title}</title>
<title>HealthProtector - ${title}</title>
<meta charset="utf-8" />
<style>
@import url('https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Trade+Winds&display=swap');
</head>
</style>
<script
src="https://code.jquery.com/jquery-3.5.1.js"
......@@ -16,7 +18,6 @@ module.exports = {
<script src="https://use.fontawesome.com/releases/v5.2.0/js/all.js"></script>
</head>
<body>
<style type="text/css">
div{
text-align:center;
......@@ -26,22 +27,29 @@ module.exports = {
}
a { text-decoration:none }
}
</div>
#help{
font-family: 'Trade Winds', cursive;
}
#info{
font-family: 'Do Hyeon', sans-serif;
}
</style>
<div style="font-family: 'Do Hyeon', sans-serif;";>
<h3 style=width:180px;float:left;><a href="/"><font color="black">HealthProtector</font></a></h3>
<h3 style=width:120px;float:left;><a href="/countKcal"><font color="black">칼로리 계산</font></a></h3>
<h3 style=width:120px;float:left;><a href="/searchGym"><font color="black">헬스장 찾기</a></h3>
<h3 style=width:120px;float:left;><a href="/foodInfo"><font color="black">식품 영양정보</font></a></h3>
<h3 style=width:150px;float:right;><i class="fas fa-info-circle fa-3x"style="font-size: 20px";></i><a href="/info"><font color="black">&nbsp;Info</font></a></h3>
<div style="font-family: 'Trade Winds', cursive;">
<h3 id ="helP" style=width:180px;float:left;><a href="/"><font color="#213b19">Health Protector</font></a></h3>
</div>
<div id="info">
<h3 style=width:130px;float:left;><a href="/countKcal"><font color="#213b19">칼로리 계산</font></a></h3>
<h3 style=width:120px;float:left;><a href="/searchGym"><font color="#213b19">헬스장 찾기</font></a></h3>
<h3 style=width:120px;float:left;><a href="/foodInfo"><font color="#213b19">식품 영양정보</font></a></h3>
<div style="color :#213b19";>
<h3 style=width:160px;float:right;>
<i class="fas fa-info-circle fa-3x"style="font-size: 20px;"></i><a href="/info"><font color="#213b19">&nbsp;Info</font></a></h3>
</div>
</div>
<hr width = "100%" color ="#213b19" style=margin:0px;>
${body}
<div style= width:100%;font-size:9px;position:fixed;bottom:0;float:left;padding:0px;background-color:#213b19;>
<h5><font color="white" font size = 2px;>Copyright(C) HealThProtector 2020</font></h5>
<div style= width:100%;font-size:9px;position:fixed;bottom:0;padding:0px;background-color:#213b19;>
<h5><font color="white" font size = 2px;>Copyright(C) HealthProtector 2020</font></h5>
</div>
</body>
</html>
......
......@@ -47,7 +47,5 @@ var app = http.createServer(function(request,response){
}
});
app.listen(process.env.PORT || 23000, function(){
console.log("Server on!");
});
\ No newline at end of file
......
var fs = require("fs");
fs.readFile("sample.txt", "utf8", function (err, data) {
console.log(data);
});
var M = {
v: "v",
f: function () {
console.log(this.v);
},
};
module.exports = M; //M을 바깥에서 사용할 수 있도록 exports한다.
// var M = {
// v: "v",
// f: function () {
// console.log(this.v);
// },
// };
var part = require("./mpart.js"); //동일한 파일에 속해있는 mpart.js의 모듈을 가져온다.
//M.f();
part.f();
var mysql = require("mysql");
var connection = mysql.createConnection({
host: "localhost",
user: "root",
password: "kdj0630",
database: "food",
});
connection.connect();
connection.query("SELECT * FROM topic", function (error, results, fields) {
if (error) {
console.log(error);
}
console.log(results);
});
connection.end();
var testFolder = "./data";
var fs = require("fs");
fs.readdir(testFolder, function (error, filelist) {
console.log(filelist);
});
Read from a file specified by fd and write to an array of ArrayBufferViews using readv().
position is the offset from the beginning of the file from where data should be read. If typeof position !== 'number', the data will be read from the current position.
The callback will be given three arguments: err, bytesRead, and buffers. bytesRead is how many bytes were read from the file.
If this method is invoked as its util.promisify()ed version, it returns a Promise for an Object with bytesRead and buffers properties.
\ No newline at end of file
const { compileFunction } = require("vm");
/*
function a(){
console.log('A');
}
*/
//java에선 함수가 값이 될 수 있다.
var a = function () {
console.log("A");
};
function slowfunc(callback) {
callback();
}
slowfunc(a);
<form action="http://localhost:3000/process_create" method="post">
<p><input type="text" name="title" /></p>
<p>
<textarea name="description" id="" cols="30" rows="10"></textarea>
</p>
<p>
<input type="submit" />
</p>
</form>
var members = ['egoing', 'k8805', 'hoya'];
console.log(members[1]); // k8805
var i = 0;
while(i < members.length){
console.log('array loop', members[i]);
i = i + 1;
}
var roles = {
'programmer':'egoing',
'designer' : 'k8805',
'manager' : 'hoya'
}
console.log(roles.designer); //k8805
console.log(roles['designer']); //k8805
for(var n in roles){
console.log('object => ', n, 'value => ', roles[n]);
}
\ No newline at end of file
var f = function(){
console.log(1+1);
console.log(1+2);
}
var a = [f];
a[0]();
var o = {
func:f
}
o.func();
\ No newline at end of file
var q = {
v1:'v1',
v2:'v2',
f1:function (){
console.log(this.v1);
},
f2:function(){
console.log(this.v2);
}
}
q.f1();
q.f2();
\ No newline at end of file
B
\ No newline at end of file
var fs = require("fs");
/*
//synchronous 동기식(순서대로) - A B C 출력
//readFileSync
console.log("A");
var result = fs.readFileSync("syntax/sample.txt", "utf8");
console.log(result);
console.log("C");
*/
//asynchronous 비동기식(성능이 좋음) - A C B 출력
console.log("A");
fs.readFile("syntax/sample.txt", "utf8", function (err, result) {
console.log(result);
});
console.log("C");