GyuhoLee

[Update] complete

var express = require('express');
var jsdom = require("jsdom");
const { JSDOM } = jsdom;
const { window } = new JSDOM();
const { document } = (new JSDOM('')).window;
var $ = jQuery = require('jquery')(window);
var express = require('express');
var app = express();
const bodyParser = require('body-parser');
app.set("view engine","ejs");
app.use(express.static(__dirname + '/public'));
app.get("/", function(req,res){
res.render("index", {low:arr[0],middle:arr[1],high:arr[2]});
res.render("index", {low:arr[0],middle:arr[1],high:arr[2],ment:ment, cloth:cloth});
});
var location;
app.get("/:location", function(req,res){
location = req.params.location;
res.render("index", {low:arr[0],middle:arr[1],high:arr[2]});
app.get("/data", function(req, res) {
res.send({
low: arr[0],
middle: arr[2],
high: arr[1],
ment: ment,
cloth: cloth
});
});
app.listen(8080, function(){
......@@ -28,11 +39,41 @@ var options = {
args: ["영통1동"]
};
/*
var arr = new Array();
var test = new PythonShell('recommend_clothes.py', options);
var data= location;
var data;
test.send(data);
test.on('message',function(message){
arr.push(message);
console.log(arr);
})
*/
var arr = new Array(1, 2, 3);
var clothes;
var cloth = new Array();
var ment = "";
app.use(bodyParser.urlencoded({extended: false}));
app.use(bodyParser.json());
app.post("/location", function(req, res){
while(arr.length){
arr.pop();
}
var data = req.body.location;
var test = new PythonShell('recommend_clothes.py', options);
test.send(data);
test.on('message',function(message){
arr.push(message);
console.log(arr);
if(arr.length == 5){
ment = arr[4];
clothes = arr[3];
cloth = clothes.split(',');
res.json({ok:true});
}
})
});
\ No newline at end of file
......
......@@ -37,3 +37,17 @@ body{
font-size: 55px;
}
.ment{
font-size: 35px;
padding: 50px 0px 50px 0px;
margin: 0px 150px 20px 150px;
border: 5px solid #94661c;
}
.cloth{
width: 230px;
height: 230px;
margin: 20px 40px 0px 40px;
border-radius: 100px;
border: solid 1px black;
}
\ No newline at end of file
......
......@@ -66,11 +66,11 @@ print(min(sens_temper), "\n", max(sens_temper), "\n", sum(sens_temper)//8)
if max(sens_temper) <= 8:
if min(sens_temper) >= -3 and min(sens_temper) <=2:
print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지")
print("쌀쌀한 날씨입니다. 생각보다 추워요!")
print("padding,yasang,jacket,pola,neet,gimo")
print("쌀쌀한 날씨입니다.\n생각보다 추워요!")
cold_danger=1
elif min(sens_temper) < -3 and min(sens_temper)>=-10:
print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지")
print("padding,yasang,jacket,pola,neet,gimo")
print("마스크, 목도리, 장갑을 착용하세요!")
cold_danger=2
if min(sens_temper) < -10 and min(sens_temper)>=-15:
......@@ -82,36 +82,34 @@ if max(sens_temper) <= 8:
print("외출시 내복 및 옷을 겹겹이 입어 주시고 많이 움직여 주세요")
cold_danger=4
elif min(sens_temper) > 2:
print("패딩, 겨울야상, 양털자켓, 폴라티, 니트, 기모바지, 스타킹")
print("패딩,겨울야상,양털자켓,폴라티,니트,기모바지")
print("외투 안에는 가벼운 옷을 추천해요!")
if max(sens_temper) >= 8 and max(sens_temper) <= 13:
print("코트, 가죽자켓, 맨투맨, 티셔츠(사계절), 바지(사계절)")
if max(sens_temper) > 8 and max(sens_temper) <= 13:
print("코트,가죽자켓,맨투맨,티셔츠(사계절),바지(사계절)")
if min(sens_temper) < 3:
print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!")
print("일교차에 유의하세요!\n추위에 약한 분들은 외투 하나 더 챙기세요!")
elif max(sens_temper) >= 13 and max(sens_temper) <= 15:
print("트렌치코트, 간절기 야상, 후드티, 여러겹 레이어드")
print("트렌치코트,간절기 야상,후드티,여러겹 레이어드")
if min(sens_temper) < 5:
print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!")
print("일교차에 유의하세요!\n추위에 약한 분들은 외투 하나 더 챙기세요!")
elif max(sens_temper) >= 12 and max(sens_temper) <= 16:
print("자켓, 셔츠, 가디건, 후드(사계절)")
print("자켓,셔츠,가디건,후드(사계절)")
if min(sens_temper) < 6:
print("일교차에 유의하세요! 추위에 약한 분들은 외투 하나 더 챙기세요!")
"""
print("일교차에 유의하세요!\n추위에 약한 분들은 외투 하나 더 챙기세요!")
elif max(sens_temper) >= 17 and max(sens_temper) <= 19:
print("가디건, 니트, 맨투맨, 후드티, 면바지, 슬랙스, 원피스")
print("가디건,니트,맨투맨,후드티,면바지,슬랙스,원피스")
if min(sens_temper) < 9:
print("일교차에 유의하세요! 얇은 외투 챙겨가세요!")
print("일교차에 유의하세요!\n얇은 외투 챙겨가세요!")
elif max(sens_temper) >= 20 and max(sens_temper) <= 22:
print("긴팔티, 후드티, 면바지, 슬랙스")
print("긴팔티,후드티,면바지,슬랙스")
if min(sens_temper) < 11:
print("일교차에 유의하세요! 얇은 외투 챙겨가세요!")
print("일교차에 유의하세요!\n얇은 외투 챙겨가세요!")
elif max(sens_temper) >= 23 and max(sens_temper) <= 26:
print("반팔티, 얇은 셔츠, 얇은 긴팔티, 반바지, 면바지")
"""
print("반팔티,얇은 셔츠,얇은 긴팔티,반바지,면바지")
......
......@@ -8,6 +8,9 @@
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css"
integrity="sha384-MCw98/SFnGE8fJT3GXwEOngsV7Zt27NXFoaoApmYm81iuXoPkFOJwJ8ERdknLPMO" crossorigin="anonymous">
<link href="https://fonts.googleapis.com/css?family=Noto+Sans+KR&display=swap" rel="stylesheet">
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT"
crossorigin="anonymous"></script>
</head>
<body>
......@@ -16,16 +19,19 @@
<img src="./image/logo.png" style="height:250px;" />
</a>
</nav>
<div class="loading" style="display:none; font-size: 100px; text-align:center; margin-top: 50%;">
<div class="loading_message">LOADING...</div>
</div>
<div class="first">
<div class="main">
<img src="./image/thermometer.jpg" class="icon">
</div>
<div class="sub">
<input type="text" id="location_input" value="영통1동" autofocus="true">
<button id="location_button" type="button" onclick="button_click()">입력</button>
<input id="location_button" type="submit" value="입력">
</div>
</div>
<div class="second">
<div class="second" style="display: none;">
<div class="main">
<span class="result_icon">
<div>최저</div>
......@@ -40,18 +46,55 @@
<div class="high temper"><%=high%>ºC</div>
</span>
</div>
<div class="sub">
<div class="sub" style="margin: 100px 0px 100px 0px;">
<div class="ment"><%=ment%></div>
</div>
<div style="text-align: center;">
<img class="cloth cloth0" />
<img class="cloth cloth1" />
<img class="cloth cloth2" />
<img class="cloth cloth3" />
<img class="cloth cloth4" />
<img class="cloth cloth5" />
</div>
</div>
<script>
$("#location_button").click(function(){
$(".first").hide();
$(".loading").show();
$.ajax({
url: '/location',
async: true,
type: 'POST',
data:{
location: $("#location_input").val()
},
dataType: 'json',
success: function(data) {
console.log(data);
$.get('/data', function(data) {
$(".low").html(data.low + "ºC");
$(".middle").html(data.middle + "ºC");
$(".high").html(data.high + "ºC");
$(".ment").html(data.ment);
for(var i = 0; i < 6; i++){
$(".cloth" + i).attr("src", "image/"+ data.cloth[i]+".jpg");
}
$(".loading").hide();
$(".second").show();
$(".first").hide();
});
}
});
});
</script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.3/umd/popper.min.js"
integrity="sha384-ZMP7rVo3mIykV+2+9J3UJ46jBk0WLaUAdn689aCwoqbBJiSnjAK/l8WvCWPIPm49"
crossorigin="anonymous"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/js/bootstrap.min.js"
integrity="sha384-ChfqqxuZUCnJSK3+MXmPNIyE6ZbWh2IMqE241rYiqJxyMiZ6OW/JmZQ5stwEULTy"
crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.3.1.min.js"
integrity="sha384-tsQFqpEReu7ZLhBV2VZlAu7zcOV+rXbYlF2cqB8txI/8aZajjp4Bqd+V6D5IgvKT"
crossorigin="anonymous"></script>
<script src = "/js/agency.js"></script>
</body>
......