kimkyeonghun

API 키 query and 링크

{"API":"AIzaSyCTR9nHa9PheDMJO9O91Oj8HRJcu81bP_M"}
\ No newline at end of file
......@@ -5,7 +5,7 @@
// 모듈 가져오기
var express = require('express')
, routes = require('./routes')
, main = require('./routes/index')
, todo = require('./routes/todo')
, login =require('./routes/login')
, http = require('http')
......@@ -37,9 +37,9 @@ app.configure('development', function(){ // 개발 버전
});
// 라우팅
app.get('/', routes.index);
app.get('/login',function(req,res){
fs.readFile('./views/login.html',function(error,data){
app.get('/Vlist', main.index);
app.get('/',function(req,res){
fs.readFile('./views/login.html/',function(error,data){
res.writeHead(200, {'Content-Type': 'text/html'});
res.end(data);
})
......
$(document).ready(function(){
// 로그인 처리
......@@ -27,7 +28,8 @@ $(document).ready(function(){
for (var i=0, len=list.length; i < len; i++){
if (list[i].userId==Info['userId']){
if (list[i].password==Info['password']){
location.href='/';
location.href='/Vlist?API='+list[i].API;
return;
}
}
}
......
......@@ -2,7 +2,14 @@
/*
* GET home page.
*/
var fs=require("fs");
exports.index = function(req, res){
var data={
'API' : req.query.API
}
fs.writeFile('./API_Key.json', JSON.stringify(data), function (err) { // todo_list.json 파일 쓰기
res.json(data);
});
res.render('index', { title: '나만의 YOUTUBE 리스트' });
};
......
......@@ -7,7 +7,6 @@ exports.LogInForm=function(req,res){
fs.readFile('./user_list.json', {
'encoding': 'utf8'
}, function (err, list) {
console.log(list);
res.json(list);
});
} else {
......
......@@ -33,11 +33,12 @@ exports.add = function(req, res1){ // 새로운 ToDo 항목 추가하기
//유튜브 api 이용 검색부분
console.log(req.body);
var datas=fs.readFileSync('./API_Key.json',{'encoding':'utf8'});
datas=JSON.parse(datas);
var optionParams = {
q:req.body.contents,
part:"snippet",
key:"AIzaSyCTR9nHa9PheDMJO9O91Oj8HRJcu81bP_M",
key: datas.API,
type:"video",
maxResults: Number(req.body.counts),
regionCode:"KR",
......
{"list":[{"contents":"구자철·기성용 &quot;남태희, 백성동 빨리 안나와?&quot;","videoId":"JFedpGFFjkM","complete":false}]}
\ No newline at end of file
{"list":[{"contents":"[하나금융그룹x손흥민 광고] &quot;함께가 힘이다. 하나가 힘이다(Full Ver)&quot; 편","videoId":"HlYWi_AdVYc","complete":false},{"contents":"손흥민 잉글랜드무대 첫 해트트릭,,,!!! 평점 10점받은 경기 ● 토트넘 vs 밀월 ● 하이라이트","videoId":"wbv5bUErdX0","complete":false},{"contents":"구자철 세계최초 두부 트래핑 도전 l 슛포러브 Shoot for Love","videoId":"1z9rGJue4pQ","complete":false},{"contents":"고려청자를 트래핑 할수 있을까요?? 구자철 선수가 직접 도전에 나서보았습니다 l 슛포러브 Shoot for Love","videoId":"Fbn85Ghgclg","complete":false},{"contents":"우리가 원했던 경기력 !!! 손흥민 멀티골, 기성용 탈압박 ● 대한민국 vs 콜롬비아 ● 하이라이트","videoId":"9dQ02l7YlQI","complete":false},{"contents":"기성용의 후배털기 ( 손흥민, 이승우, 정우영, 황희찬, 황의조)","videoId":"lHIZJ58UQow","complete":false}]}
\ No newline at end of file
......
{"list":[{"fname":"김경훈","userId":"kkh115505@naver.com","API":"abcdefg","password":"1234"}]}
\ No newline at end of file
{"list":[{"fname":"김경훈","userId":"kkh115505@naver.com","API":"AIzaSyCTR9nHa9PheDMJO9O91Oj8HRJcu81bP_M","password":"1234"}]}
\ No newline at end of file
......
......@@ -7,7 +7,6 @@
</head>
<body>
<h1><%= title %></h1>
<p>Welcome to <%= title %></p>
<form class="form-inline"> <!-- 새로운 ToDo 항목 추가 -->
<div class="form-group">
<input type="text" class="form-control" id="new_todo" placeholder="유튜브명">
......
......@@ -24,18 +24,18 @@
<div class="row justify-content-center">
<div class="col-md-8">
<div class="card">
<div class="card-header">Login</div>
<div class="card-header">로그인</div>
<div class="card-body">
<form action="" method="">
<div class="form-group row">
<label for="userid" class="col-md-4 col-form-label text-md-right">E-Mail Address</label>
<label for="userid" class="col-md-4 col-form-label text-md-right">아이디(이메일)</label>
<div class="col-md-6">
<input type="text" id="userid" class="form-control" name="userid" required autofocus>
</div>
</div>
<div class="form-group row">
<label for="password" class="col-md-4 col-form-label text-md-right">Password</label>
<label for="password" class="col-md-4 col-form-label text-md-right">패스워드</label>
<div class="col-md-6">
<input type="password" id="password" class="form-control" name="password" required>
</div>
......@@ -44,7 +44,7 @@
<button type="submit" id="login-submit" class="btn btn-primary">
로그인
</button>
<button type="button" id="makeInfo" class="btn btn-primary">
<button type="button" id="makeInfo" class="btn btn-success">
회원가입하기
</button>
</a>
......
......@@ -36,7 +36,7 @@
<label class="col-md-4 control-label" for="ssnein">YouTube Api Key</label>
<div class="col-md-5">
<input id="ssnein" name="ssnein" type="text" placeholder="YouTube Api Key" class="form-control input-md" required="">
<span class="help-block">링크 걸어줍시다.</span>
<span class="help-block"><a href="https://console.developers.google.com/start">API키 발급받기</a></span>
</div>
</div>
<!-- Text input-->
......