Toggle navigation
Toggle navigation
This project
Loading...
Sign in
김건희
/
OSSW_Weather_Briefing
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
Seokjin
2022-06-03 00:36:20 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
33cd5d386241837df4fe54cb4bffed5e49c315e1
33cd5d38
1 parent
450cc659
[UPDATE]Clothes.recommend
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
125 additions
and
0 deletions
weather_briefing/server/clothes.js
weather_briefing/server/clothes.js
0 → 100644
View file @
33cd5d3
let
express
=
require
(
'express'
);
let
bodyParser
=
require
(
'body-parser'
);
let
mongoose
=
require
(
'mongoose'
);
let
cors
=
require
(
'cors'
);
let
app
=
express
();
app
.
use
(
cors
());
let
logid
=
null
;
const
uri
=
'mongodb+srv://sjieu17:tjrwls147714@cluster0.lc6pe.mongodb.net/weather_briefing?retryWrites=true&w=majority'
;
//const uri = 'mongodb+srv://tahmkench:dkrldnsl7@cluster0.vzipl.mongodb.net/?retryWrites=true&w=majority';
let
db
=
mongoose
.
connect
(
uri
,
(
err
)
=>
{
if
(
err
)
{
console
.
log
(
err
.
message
);
}
else
{
console
.
log
(
'Succesfully Connected!'
);
}
});
var
clothesSchema
=
new
mongoose
.
Schema
({
gender
:
Number
,
weather
:
Number
,
top
:
String
,
bottom
:
String
});
var
Clothes
=
mongoose
.
model
(
'clothes'
,
clothesSchema
);
app
.
use
(
bodyParser
.
json
());
app
.
use
(
bodyParser
.
urlencoded
({
limit
:
'1gb'
,
extended
:
false
}));
app
.
post
(
'/api/addstyple'
,
(
req
,
res
)
=>
{
Clothes
.
findOne
({
gender
:
req
.
body
.
gender
,
weather
:
req
.
body
.
weather
,
top
:
req
.
top
,
bottom
:
req
.
bottom
},
(
err
,
clothes
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
registerSuccess
:
'-1'
});
else
if
(
clothes
){
res
.
json
({
registerSuccess
:
'0'
});
}
else
{
const
new_user
=
new
Clothes
(
req
.
body
);
new_user
.
save
((
err
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
registerSuccess
:
'-1'
});
else
return
res
.
status
(
200
).
json
({
registerSuccess
:
'1'
});
});
}
});
});
app
.
post
(
'/api/clothes'
,
(
req
,
res
)
=>
{
Clothes
.
findOne
({
gender
:
req
.
body
.
gender
,
weather
:
req
.
body
.
weather
},
(
err
,
clothes
)
=>
{
if
(
err
)
return
res
.
status
(
500
).
json
({
loginSuccess
:
false
});
else
if
(
clothes
)
{
console
.
log
(
clothes
);
// logid={id:clothes.id,password:clothes.password,name:clothes.name,gender:clothes.gender};
return
res
.
status
(
200
).
json
({
loginSuccess
:
true
});
}
else
return
res
.
status
(
404
).
json
({
loginSuccess
:
false
});
});
});
app
.
listen
(
4000
,
()
=>
console
.
log
(
'Server On 4000'
));
// var express = require('express');
// var app = express();
// var client_id = 'EaHxnjlhHWNjVnHp2eF9';
// var client_secret = 'gPbFbMUxq_';
// app.get('/search/blog', function (req, res) {
// var api_url = 'https://openapi.naver.com/v1/search/shop.json?query=' + encodeURI(req.query.query); // json 결과
// // var api_url = 'https://openapi.naver.com/v1/search/blog.xml?query=' + encodeURI(req.query.query); // xml 결과
// var request = require('request');
// var options = {
// url: api_url,
// headers: {'X-Naver-Client-Id':client_id, 'X-Naver-Client-Secret': client_secret}
// };
// request.get(options, function (error, response, body) {
// if (!error && response.statusCode == 200) {
// res.writeHead(200, {'Content-Type': 'text/json;charset=utf-8'});
// res.end(body);
// } else {
// res.status(response.statusCode).end();
// console.log('error = ' + response.statusCode);
// }
// });
// });
// app.listen(4000, function () {
// console.log('http://127.0.0.1:3000/search/blog?query=검색어 app listening on port 3000!');
// });
// //
\ No newline at end of file
Please
register
or
login
to post a comment