GyuhoLee

[Add] To EJS and express

......@@ -11,7 +11,7 @@
"skipFiles": [
"<node_internals>/**"
],
"program": "${workspaceFolder}\\test.js"
"program": "${workspaceFolder}\\app.js"
}
]
}
\ No newline at end of file
......
var express = require('express');
var app = express();
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]});
});
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.listen(8080, function(){
console.log('Server On!');
});
const {PythonShell} = require('python-shell');
var options = {
mode: 'text',
pythonOptions: ['-u'],
scriptPath: '',
encoding: 'utf8',
args: ["영통1동"]
};
var arr = new Array();
var test = new PythonShell('recommend_clothes.py', options);
var data= location;
test.send(data);
test.on('message',function(message){
arr.push(message);
console.log(arr);
})
\ No newline at end of file
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>OSSW</title>
<link rel="stylesheet" href="/style.css" crossorigin="anonymous">
<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">
</head>
<body>
<nav class="navbar navbar-light bg-light" style="border-bottom: 1px solid lightgray;">
<a class="navbar-brand" href="#" style="margin-left: 15px;">
<img src="/image/logo.png" style="height:250px;"/>
</a>
</nav>
<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" onclick="button_click()">입력</button>
</div>
<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/app.js"></script>
</body>
</html>
\ No newline at end of file
const locationData = function button_click(){
var dTemp = $('#location_input').val();
location.href="/result.html";
return dTemp;
}
exports.locationData = locationData;
\ No newline at end of file
var jsdom = require("jsdom");
const { JSDOM } = jsdom;
const { window } = new JSDOM();
const { document } = (new JSDOM('')).window;
var $ = jQuery = require('jquery')(window);
const appdata = require('../../app');
var data = "영통1동";
function button_click(){
data= $('#location_input').val();
$(".low").text(appdata.tLow);
}
exports.location = data;
\ No newline at end of file
......@@ -18,7 +18,6 @@ for cell in sheet['E']:
sys.stdin.reconfigure(encoding='utf-8')
sys.stdout.reconfigure(encoding='utf-8')
area = input()
print(area)
col = code.index(area)
area_code_index = 'B' + str(col+1)
area_code = sheet[area_code_index].value
......
var http = require('http');
var fs = require('fs');
var app = http.createServer(function(request,response){
var url = request.url;
if(request.url == '/'){
url = '/index.html';
}
if(request.url == '/favicon.ico'){
response.writeHead(404);
response.end();
return;
}
response.writeHead(200);
response.end(fs.readFileSync(__dirname + url));
});
app.listen(8080);
const {PythonShell} = require('python-shell');
var options = {
mode: 'text',
pythonOptions: ['-u'],
scriptPath: '',
encoding: 'utf8',
args: ["영통1동"]
};
const appdata = require('./js/app.js');
var arr;
var test = new PythonShell('recommend_clothes.py', options);
var data= appdata.locationData();
test.send(data);
test.on('message',function(message){
arr = message.split('\n');
console.log(arr);
})
\ No newline at end of file
......@@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8">
<title>OSSW</title>
<link rel="stylesheet" href="/style.css" crossorigin="anonymous">
<link rel="stylesheet" href="../css/style.css" crossorigin="anonymous">
<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">
......@@ -13,34 +13,46 @@
<body>
<nav class="navbar navbar-light bg-light" style="border-bottom: 1px solid lightgray;">
<a class="navbar-brand" href="#" style="margin-left: 15px;">
<img src="/image/logo.png" style="height:250px;"/>
<img src="./image/logo.png" style="height:250px;" />
</a>
</nav>
<div class = "main">
<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>
</div>
</div>
<div class="second">
<div class="main">
<span class="result_icon">
<div>최저</div>
<div class="low temper">3ºC</div>
<div class="low temper"><%=low%>ºC</div>
</span>
<span class = "result_icon">
<span class="result_icon">
<div>평균</div>
<div class="middle temper">5ºC</div>
<div class="middle temper"><%=middle%>ºC</div>
</span>
<span class = "result_icon">
<span class="result_icon">
<div>최고</div>
<div class="high temper">7ºC</div>
<div class="high temper"><%=high%>ºC</div>
</span>
</div>
<div class = "sub">
<div class="sub">
</div>
<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/app.js"></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>
</html>
\ No newline at end of file
......