출처: kimkkikki.github.io/flask/2019/03/15/flask_react_router.html

 

Kimkkikki Blog

이런저런 개발이야기

kimkkikki.github.io

 

테스트하다보니 현재 기준으로 안되는 부분들이 있어서 일부 수정했다.

package.json

{
  "name": "flask_react_router",
  "version": "1.0.0",
  "private": true,
  "devDependencies": {
    "@babel/core": "^7.2.2",
    "@babel/plugin-proposal-class-properties": "^7.3.0",
    "@babel/plugin-proposal-decorators": "^7.3.0",
    "@babel/polyfill": "^7.2.5",
    "@babel/preset-env": "^7.3.1",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.5",
    "css-loader": "^2.1.0",
    "file-loader": "^3.0.1",
    "mini-css-extract-plugin": "^0.5.0",
    "postcss-loader": "^3.0.0",
    "sass-loader": "^7.1.0",
    "style-loader": "^0.23.1",
    "webpack": "^4.46.0",
    "webpack-cli": "^4.5.0"
  },
  "dependencies": {
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "react-router-dom": "^4.3.1"
  }
}

private: true 추가

 

App.js

import React from 'react'
import { Route } from 'react-router-dom';
import First from './containers/First';
import Second from './containers/Second';

const App = () => {    
	return (
		<>
			<Route path='/first' component={ First } />
			<Route path='/second' component={ Second } />
		</>
	);
}

export default App;

함수 베이스로 수정

 

First.js, Second.js

import React, { Component } from 'react';

const First = () => {
	return (
		<div>Hello First</div>
	);
};

export default First;

이것도 함수 베이스로 수정

 

잘 돌아간다.

css 파일이 없어서 생기는 에러는 import한 css 파일이 없어서 생긴 문제라서 빈 css 파일을 만들어서 import하고 webpack 해주면 flask_react_router.css이 생성되면서 해결된다.

String.prototype.toDate = function(format){
	var normalized      = this.replace(/[^a-zA-Z0-9]/g, '-');
	var normalizedFormat= format.toLowerCase().replace(/[^a-zA-Z0-9]/g, '-');
	var formatItems     = normalizedFormat.split('-');
	var dateItems       = normalized.split('-');

	var monthIndex  = formatItems.indexOf("mm");
	var dayIndex    = formatItems.indexOf("dd");
	var yearIndex   = formatItems.indexOf("yyyy");
	var hourIndex     = formatItems.indexOf("hh");
	var minutesIndex  = formatItems.indexOf("ii");
	var secondsIndex  = formatItems.indexOf("ss");

	var today = new Date();

	var year  = yearIndex>-1  ? dateItems[yearIndex]    : today.getFullYear();
	var month = monthIndex>-1 ? dateItems[monthIndex]-1 : today.getMonth()-1;
	var day   = dayIndex>-1   ? dateItems[dayIndex]     : today.getDate();

	var hour    = hourIndex>-1      ? dateItems[hourIndex]    : today.getHours();
	var minute  = minutesIndex>-1   ? dateItems[minutesIndex] : today.getMinutes();
	var second  = secondsIndex>-1   ? dateItems[secondsIndex] : today.getSeconds();

	return new Date(year,month,day,hour,minute,second);
};

Date.prototype.format = function(f) {
    if (!this.valueOf()) return " ";
 
    var weekName = ["일요일", "월요일", "화요일", "수요일", "목요일", "금요일", "토요일"];
    var d = this;
     
    return f.replace(/(yyyy|yy|MM|dd|E|hh|mm|ss|a\/p)/gi, function($1) {
        switch ($1) {
            case "yyyy": return d.getFullYear();
            case "yy": return (d.getFullYear() % 1000).zf(2);
            case "MM": return (d.getMonth() + 1).zf(2);
            case "dd": return d.getDate().zf(2);
            case "E": return weekName[d.getDay()];
            case "HH": return d.getHours().zf(2);
            case "hh": return ((h = d.getHours() % 12) ? h : 12).zf(2);
            case "mm": return d.getMinutes().zf(2);
            case "ss": return d.getSeconds().zf(2);
            case "a/p": return d.getHours() < 12 ? "오전" : "오후";
            default: return $1;
        }
    });
};
 
String.prototype.string = function(len){var s = '', i = 0; while (i++ < len) { s += this; } return s;};
String.prototype.zf = function(len){return "0".string(len - this.length) + this;};
Number.prototype.zf = function(len){return this.toString().zf(len);};

 

사용법

const str = "2020-12-17";
const d = str.toDate("yyyy-MM-dd");
const dstr = d.format("yyyy-MM-dd");

 

출처: https://stove99.tistory.com/46

stackoverflow.com/questions/5619202/converting-a-string-to-a-date-in-javascript

GROUP BY DATE(컬럼명), HOUR(컬럼명), FLOOR(MINUTE(컬럼명)/1)

'DB > MySQL' 카테고리의 다른 글

CentOS7, MySQL8 에서 root 계정 비밀번호를 분실한 경우  (0) 2022.06.22
SELECT 와 UPDATE 동시에 하기  (0) 2021.06.17
5.7 DB 파일로 복원  (0) 2020.06.04
외부 접근 허용  (0) 2019.10.28
SELECT UPDATE  (0) 2011.06.30

0. MySQL 실행 중지

설치경로\bin\mysqld\mysqladmin -u root -p shutdown

 

1.

기본 경로: C:\ProgramData\MySQL\MySQL Server 5.7\Data\

기존 DB 스키마 폴더와 ibdata1 파일을 덮어 씌우기

 

2. MySQL 재시작

 

'DB > MySQL' 카테고리의 다른 글

SELECT 와 UPDATE 동시에 하기  (0) 2021.06.17
datetime 컬럼을 분단위로 group by 하기  (1) 2020.09.29
외부 접근 허용  (0) 2019.10.28
SELECT UPDATE  (0) 2011.06.30
Create table select, Insert select  (0) 2011.06.17

1. 방화벽

인바운드규칙 / 연결허용 / tcp 3306

 

2. DB의 권한

-- 새 유저 생성할거면 이 구문부터
CREATE USER 계정이름@'%' IDENTIFIED BY '비밀번호';

-- 기존유저 혹은 새유저에 권한 부여
GRANT ALL PRIVILEGES ON 데이터베이스이름.* TO 계정이름@'%';
FLUSH PRIVILEGES;

 

여기까지 해서 해결되었지만 안된다면 이 분 글을 더 참고하면 됨

출처: https://blog.jiktong.kr/2221

'DB > MySQL' 카테고리의 다른 글

datetime 컬럼을 분단위로 group by 하기  (1) 2020.09.29
5.7 DB 파일로 복원  (0) 2020.06.04
SELECT UPDATE  (0) 2011.06.30
Create table select, Insert select  (0) 2011.06.17
스키마내 테이블 수  (0) 2011.06.17

+ Recent posts