This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def home(request): | |
# posts = Post.objects.all() | |
url_parameter = request.GET.get("q", None) # request에서 query 값을 인식한다는 뜻이다. | |
# 중요한 건 여깁니다. “q”는 query의 약자로 사용자가 질문한 값을 여기서 get하겠다는 의미 | |
if url_parameter: # 사용자가 입력한 query 값이 있다면, | |
results = Post.objects.filter(title__contains=url_parameter) | |
else: | |
results = Post.objects.all() # 없으면 저장된 객체값을 모두 보여달라는 뜻 | |
if request.is_ajax(): # 요청 자체가 AJAX라면, | |
html = render_to_string( # 결과값을 부분만 보여주는 HTML 렌더링 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{% load socialaccount %} | |
{% providers_media_js %} | |
{% load static %} | |
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<title>Document</title> | |
<script |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const _formData = { | |
image: "image", | |
image: fs.createReadStream(path.join(__dirname + "/sean.jpg")), // , // FILE 이름 | |
}; | |
const _req = await request.post( | |
{ | |
url: api_url, | |
formData: _formData, | |
headers: { | |
"X-Naver-Client-Id": process.env.NAVER_CLIENT_ID, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var form = new FormData(); | |
form.append("image", fs.createReadStream(path.join(__dirname + "/sean.jpg"))); | |
axios | |
.post(api_url, form, { | |
headers: { | |
// axios에서는 content-type을 자동으로 바꿔주지 않기 때문에 | |
// 다음과 같이 header를 넣어주어야 합니다 | |
...form.getHeaders(), | |
"X-Naver-Client-Id": process.env.NAVER_CLIENT_ID, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const path = require("path"); | |
const multer = require("multer"); | |
const bodyParser = require("body-parser"); | |
const FormData = require("form-data"); | |
const fs = require("fs"); | |
const axios = require("axios"); | |
// 클로바 관리 | |
axios.defaults.timeout = 10000; | |
require("dotenv").config(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
html(lang="en") | |
head | |
meta(charset="UTF-8") | |
meta(name="viewport", content="width=device-width, initial-scale=1.0") | |
title NAVER AI API TEST | |
link(rel="stylesheet", href="/css/main.css") | |
body | |
.container | |
.title Thử đoán độ tuổi qua gương mặt của bạn bằng trí tuệ nhân tạo - Liệu bạn có gương mặt trẻ hay không? 🙉 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// import React, {Component} from 'react' | |
import React, {useState} from 'react' | |
// class EventPractice extends Component{ | |
// state = { | |
// message : "", | |
// username: "" | |
// } | |
// // constructor(props){ | |
// // super(props) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require("path"); | |
const express = require("express"); | |
const bodyParser = require("body-parser"); | |
const cookieParser = require("cookie-parser"); | |
const morgan = require("morgan"); | |
const flash = require("connect-flash"); // req.flash() requires sessions | |
require("dotenv").config(); | |
const { sequelize } = require("./models"); // ./models === ./passport/(index.js) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"development": { | |
"username": "username", | |
"password": "password", | |
"database": "sns", | |
"host": "127.0.0.1", | |
"dialect": "mysql" | |
}, | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const Sequelize = require("sequelize"); | |
const env = process.env.NODE_ENV || "development"; | |
const config = require("../config/config.json")[env]; | |
const db = {}; | |
const sequelize = new Sequelize( | |
config.database, | |
config.username, | |
config.password, | |
config |
OlderNewer