Commit f6df8757 authored by Lee SeoYeon's avatar Lee SeoYeon
Browse files

0113

parent 558b1436
This diff is collapsed.
...@@ -8,7 +8,7 @@ function App() { ...@@ -8,7 +8,7 @@ function App() {
const [state, setState] = useState(false); const [state, setState] = useState(false);
const [search, setSearch] = useState(""); const [search, setSearch] = useState("");
const user = isAuthenticated() const user = isAuthenticated()
if (state !== false) { if (state !== false) {
return <Redirect to={{ return <Redirect to={{
pathname: `/search/${search}`, pathname: `/search/${search}`,
...@@ -26,13 +26,26 @@ function App() { ...@@ -26,13 +26,26 @@ function App() {
return ( return (
<Container className="vh-100 d-flex justify-content-md-center align-items-center"> <Container className="vh-100 d-flex justify-content-md-center align-items-center">
<Col md={6} lassName=" d-flex justify-content-center"> <Col md={6} style={{marginTop:140}}>
<Row style={{marginBottom:20}}> <Row style={{marginBottom:20}}>
<Image src={ohuh} /> <Image src={ohuh} />
</Row> </Row>
<Row>
<Navbar bg="#fff" variant="light">
<Nav className="mr-auto">
{user ? <Nav.Link onClick={() => handleLogout()}>로그아웃</Nav.Link>
: (
<>
<Nav.Link href="/signup">회원가입</Nav.Link>
<Nav.Link href="/login">로그인</Nav.Link>
</>
)}
</Nav>
</Navbar>
</Row>
<Row style={{marginBottom:500}}> <Row style={{marginBottom:500}}>
<Form className="vw-100" onSubmit={handleSubmit}> <Form className="vw-100" onSubmit={handleSubmit}>
<InputGroup> <InputGroup style={{width:560}}>
<Form.Control <Form.Control
size="lg" size="lg"
placeholder="검색어를 입력하세요." placeholder="검색어를 입력하세요."
...@@ -51,4 +64,4 @@ function App() { ...@@ -51,4 +64,4 @@ function App() {
); );
} }
export default App; export default App;
\ No newline at end of file
...@@ -75,4 +75,4 @@ function Signup() { ...@@ -75,4 +75,4 @@ function Signup() {
) )
} }
export default Signup export default Signup
\ No newline at end of file
...@@ -3,6 +3,7 @@ const config = { ...@@ -3,6 +3,7 @@ const config = {
port: process.env.PORT || 3001, port: process.env.PORT || 3001,
jwtSecret: process.env.JWT_SECRET || 'My_Secret_Key', jwtSecret: process.env.JWT_SECRET || 'My_Secret_Key',
mongoDbUri: process.env.MONGODB_URI || 'mongodb://localhost/search-page', mongoDbUri: process.env.MONGODB_URI || 'mongodb://localhost/search-page',
cookieMaxAge: 60 * 60 * 24 * 7 * 1000
} }
export default config export default config
\ No newline at end of file
import Review from '../models/Review.js' import Review from '../models/Review.js'
import cheerio from "cheerio"; import cheerio from "cheerio";
import jschardet from 'jschardet' // import jschardet from 'jschardet'
import iconv from 'iconv' // import iconv from 'iconv'
import fs from 'fs' // import fs from 'fs'
import axios from 'axios'; import axios from 'axios';
const Iconv = iconv.Iconv // const Iconv = iconv.Iconv
const search = async (req, res) => { const search = async (req, res) => {
const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com&page_no=1" const url = "https://www.google.com/search?q=" + encodeURI(req.params.search) + "+site%3Atistory.com&page_no=1"
const editUrl = /(http(s)?:\/\/)([a-z0-9\w]+\.*)+[a-z0-9]{2,4}/gi const editUrl = /(http(s)?:\/\/)([a-z0-9\w]+\.*)+[a-z0-9]{2,4}/gi
axios.get(url) axios.get(url)
// .then(anyToUtf8) // .then(anyToUtf8)
.then((html) => { .then((html) => {
// fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' }); // fs.writeFileSync("googlez.txt", '\ufeff' + html, { encoding: 'utf8' });
...@@ -39,11 +39,11 @@ const search = async (req, res) => { ...@@ -39,11 +39,11 @@ const search = async (req, res) => {
console.log(reviews) console.log(reviews)
res.send(reviews) res.send(reviews)
}) })
function anyToUtf8(str) { // function anyToUtf8(str) {
const { encoding } = jschardet.detect(str); // 웹페이지 문서의 인코딩 타입을 확인 // const { encoding } = jschardet.detect(str); // 웹페이지 문서의 인코딩 타입을 확인
const iconv = new Iconv(encoding, "utf-8//translit//ignore"); // euc-kr 인코딩변환 // const iconv = new Iconv(encoding, "utf-8//translit//ignore"); // euc-kr 인코딩변환
return iconv.convert(str).toString(); // return iconv.convert(str).toString();
} // }
// try { // try {
// const newPlace = await new Place({ // const newPlace = await new Place({
// name: req.params.search, // name: req.params.search,
......
...@@ -2,6 +2,8 @@ import express from 'express' ...@@ -2,6 +2,8 @@ import express from 'express'
import connectDb from './utils/connectDb.js' import connectDb from './utils/connectDb.js'
import placeRouter from './routes/place.routes.js' import placeRouter from './routes/place.routes.js'
import reviewRouter from './routes/review.routes.js' import reviewRouter from './routes/review.routes.js'
import userRouter from "./routes/user.routes.js"
import authRouter from "./routes/auth.routes.js"
connectDb() connectDb()
...@@ -13,6 +15,8 @@ app.use(express.json()) ...@@ -13,6 +15,8 @@ app.use(express.json())
app.use(placeRouter) app.use(placeRouter)
app.use(reviewRouter) app.use(reviewRouter)
app.use(userRouter)
app.use(authRouter)
app.get('/', (req, res) => { app.get('/', (req, res) => {
console.log("/ req.body", req.body) console.log("/ req.body", req.body)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment