vue --version

 

/* Vue.js 설치 안 되었을 때 */

 

npm i -g @vue/cli

 

vue --version

 

npm i -g @vue/cli-init

vue init webpack simple

 

/* simple을 프로젝트 이름이라고 생각하시면 됩니다.(폴더로 생성된다) */

 

cd simple

npm run dev

 

 

/*VS Code로 vue 개발하는데 사용하는 최애 확장프로그램 모음*/

 

Vetur

Vue VSCode Snippets

Material Icon Theme

 

 

 

npm run build   /* 배포용으로 만들 때 */

인텔리제이 static ( css, js, index )

 

 

axios 설치 방법

 

npm install --save axios

 

/* 사용 위치의 <script> 아래에 import axios from “axios”; 를 코딩한다 */

 

 

 

폴더구조

 

 

 

 

JsonCrud.vue

 

<script>
import axios from "axios";


export default {
 data() {
   return {
     id:0,
     title: '',
     userId: 0,
     completed: false
   }
 },
 methods: {
   get: function () {
     let dataCollection = []
     axios.get('http://localhost:4000/todo')
       .then(res => {
         dataCollection = res.data
         console.log('dataCollection: ', dataCollection);
         dataCollection.forEach(data => {
           document.querySelector('.print-data').innerHTML
             += `<li>id: ${data.id} <br>title: ${data.title} <br> content: ${data.completed}</li>`
         })
       })
       .catch((error) => console.log(error))
   },
   submit: function () {
     const todoParams = {
       id: this.id,
       userId: this.userId,
       title: this.title,
       completed: this.completed
     }


     axios.post(`http://localhost:4000/todo`, todoParams)
       .then(res => {
         console.log('res: ', res);
       })
       .catch(error => {
         console.log('error: ', error);
       })
   },
   put: function () {
     const todoParams = {
       id: this.id,
       userId: this.userId,
       title: this.title,
       completed: this.completed
     }


     axios.put(`http://localhost:4000/todo/${this.id}`, todoParams)
       .then(res => {
         console.log('res: ', res);
       })
       .catch(error => {
         console.log('error: ', error);
       })
   },
   del: function () {
     axios.delete(`http://localhost:4000/todo/${this.id}`)
       .then(res => {
         console.log('res: ', res);
       })
       .catch(error => {
         console.log('error: ', error);
       })
   }
 }
}
</script>


<template>
<div id="app">
   <div class="box-wrap">
     <div class="box">아이디</div>
     <div class="box"><input v-model="id" placeholder="아이디를 입력"></div>
   </div>


   <div class="box-wrap">
     <div class="box">제목</div>
     <div class="box"><input v-model="title" placeholder="제목을 입력"></div>
   </div>


   <div class="box-wrap">
     <div class="box">사용자 아이디</div>
     <div class="box"><input v-model="userId" placeholder="사용자 아이디를 입력"></div>
   </div>


   <div class="box-wrap">
     <div class="box">성공여부</div>
     <div class="box"><input v-model="completed" placeholder="성공여부를 입력"></div>
   </div>


   <div class="box-wrap">
     <div class="box"><button class="button" v-on:click="get" type="button">GET</button></div>
     <div class="box"><button class="button" v-on:click="submit" type="button">POST</button></div>
     <div class="box"><button class="button" v-on:click="put" type="button">PUT</button></div>
     <div class="box"><button class="button" v-on:click="del" type="button">DELETE</button></div>
   </div>


   <div class="print-data">
     <ul></ul>
   </div>
</div>
</template>


<style>
.box-wrap {
 display: table;
 width: 100%;
 height: 30px;
 table-layout: fixed;
}


.box-wrap .box {
 display: table-cell;
 text-align: left;
 vertical-align: middle;
//border: 1px grey solid;
}
.button {
 width: 100%;
 height: 30px;
}
</style>


App.vue
<template>
 <JsonCrud></JsonCrud>
</template>


<script>




import JsonCrud from "./components/JsonCrud.vue";


export default {
 components: {
   'JsonCrud': JsonCrud
 }
}
</script>


<style>


</style>

 

 

 

App.vue

<template>
 <JsonCrud></JsonCrud>
</template>


<script>




import JsonCrud from "./components/JsonCrud.vue";


export default {
 components: {
   'JsonCrud': JsonCrud
 }
}
</script>


<style>


</style>

 

 

 

 

main.js

import Vue from 'vue'
import App from './App.vue'


new Vue({
 el: '#app',
 render: h => h(App)
})

 

 

index.html

<!DOCTYPE html>
<html>
 <head>
   <meta charset="utf-8">
   <meta name="viewport" content="width=device-width,initial-scale=1.0">
   <link rel="shortcut icon" href="src/assets/favicon.ico" type="image/x-icon">
   <link rel="icon" href="src/assets/favicon.ico" type="image/x-icon">
   <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
   <link href="https://fonts.googleapis.com/css?family=Ubuntu" rel="stylesheet">
   <title>simple</title>
 </head>
 <body>
   <div id="app"></div>
   <!-- built files will be auto injected -->
 </body>
</html>

 

 

 

 

SpringBoot에 배포할 버전 만들기

 

npm run build

 

실행 후 결과물

 

 

부분만 배포합니다.

 

 

Json 파일

db2.json
0.03MB

 

 

 

 

서버 실행

 

json-server --watch db2.json --port 4000

 

 

결과

'코드 정리' 카테고리의 다른 글

AWS_EC2 배포 관련 (SpringBoot_gradle )  (0) 2024.01.22
GitHub_Team  (1) 2023.11.25
스프링 시큐리티_구글 소셜로그인_DB연결  (0) 2023.11.01
Vue.js basic  (0) 2023.11.01
local=> Git  (0) 2023.11.01

구글 소셜 로그인

 

1. Google 클라우드 플랫폼 접속
2. API 및 서비스 => 사용자 인증 정보 
3. 구글 프로젝트 생성 
4. +사용자 인증 정보 만들기 OAuth 클라이언트 ID
5. 동의 화면 구성 선택 => 외부 설정 => 애플리케이션 이름 지정 ( 로그인 시도할때 보이는 화면 ) => API 범위
...email, ...profile, ...openid 설정 ( 위에 3개 )  
6.  애플리케이션 유형 => 웹애플리케이션 설정
7. 승인된 리디렉션 URI => URI 지정 ( http://localhost:8989/login/oauth2/code/google ) 8989 프로젝트 서버 주소
8. 생성된 클라이언트 ID, 보안비밀번호 확인 
9. build.gradle에 라이브러리 추가 (  implementation 'org.springframework.boot:spring-boot-starter-oauth2-client' )
10. application-oauth.properties생성 추가 => 
#생성된 클라이언트 아이디
spring.security.oauth2.client.registration.google.client-id= 생성 된 클라이언트 ID 넣기

#생성된 클라이언트 비밀번호
spring.security.oauth2.client.registration.google.client-secret=생성 된 클라이언트 보안 비밀번호 추가

spring.security.oauth2.client.registration.google.scope=email

11. application.properties => spring.profiles.include=oauth 추가 

12. SecurityConfig 클래스 추가 => 
  @Bean
    public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {

        http.authorizeHttpRequests((auth) -> {
//            auth.antMatchers("/sample/all").permitAll();
//            auth.antMatchers("/sample/member").hasRole("USER");
            auth.antMatchers("/h2-console/**").permitAll();
        });

//        http.authorizeRequests()
//                .antMatchers("/h2-console/**").permitAll();

        http.csrf()
                .ignoringAntMatchers("/h2-console/**")
                .and().headers().frameOptions().sameOrigin();  // 여기!

        http.formLogin();
        http.csrf().disable();
        http.logout(logout -> logout
        // 로그아웃 요청을 처리할 URL 설정
                        .logoutUrl("/logout")
                // 로그아웃 성공 시 리다이렉트할 URL 설정
                        .logoutSuccessUrl("/login")
                // 로그아웃 핸들러 추가 (세션 무효화 처리)
                        .addLogoutHandler(((request, response, authentication) -> {
                            HttpSession session = request.getSession();
                            session.invalidate();
                        }))
                // 로그아웃 성곤 핸들러 추가 (리다이렉션 처리)
                        .logoutSuccessHandler(((request, response, authentication) ->
                                response.sendRedirect("/login")))
                // 로그아웃 시 쿠키 삭제 설정 (예: "remember-me" 쿠키 삭제)
                        .deleteCookies("remember-me")
        );
        http.oauth2Login().successHandler(successHandler());

        http.rememberMe().tokenValiditySeconds(60*60*24*7).userDetailsService(userDetailsService);

        return http.build();
    }

 

 

 

 

 

 

 

 

1. build.gradle 추가 

    runtimeOnly 'com.mysql:mysql-connector-j'
    implementation 'org.springframework.boot:spring-boot-starter-jdbc'
    implementation 'org.bgee.log4jdbc-log4j2:log4jdbc-log4j2-jdbc4:1.16'
    implementation 'org.springframework.boot:spring-boot-starter'
    runtimeOnly 'mysql:mysql-connector-java'

2. application.properties 추가

spring.datasource.driver-class-name=net.sf.log4jdbc.sql.jdbcapi.DriverSpy
spring.datasource.url=jdbc:log4jdbc:mysql://localhost:3306/security?serverTimezone=UTC&characterEncoding=UTF-8


spring.datasource.username=security
spring.datasource.password=security

 

 

'코드 정리' 카테고리의 다른 글

GitHub_Team  (1) 2023.11.25
Vue.js 실전_ 연습 순서  (0) 2023.11.08
Vue.js basic  (0) 2023.11.01
local=> Git  (0) 2023.11.01
파이썬 기초_1  (1) 2023.10.24

 

 

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Vue Sample</title>
</head>
<body>
    <div id="app">
        {{message}}
    </div>
    
    <script src="https://cdn.jsdelivr.net/npm/vue@2.5.2/dist/vue.js"></script>

    <script>

        new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue.js!'
            }

        });

    </script>

</body>
</html>

절차 
1. new Vue() 인스턴스 안에 el, data 를 정의하고 인스턴스 생성 
2. <div id='app'>{{message}}</div> 해당 돔에 인스턴스 부착됨
3. data 속성의 message 값 Hello Vue.js!가 {{message}}와 치환되서 화면에 출력

유효 범위
1.뷰 라이브러리 파일 로딩 
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.2/dist/vue.js"></script>

2. 인스턴스 객체 생성
        new Vue({
            el: '#app',
            data: {
                message: 'Hello Vue.js!'
            }

        });

3.  el:'#app' Vue 객체 스코프에 인스턴스 연결 
    <div id="app">
        {{message}}
    </div>

4. 인스턴스 내용 ( data )이 화면 요소로 변환 
    <div id="app">
        Hello Vue.js!
    </div>

5. 변환된 요소가 화면에 출력


 

 

'코드 정리' 카테고리의 다른 글

Vue.js 실전_ 연습 순서  (0) 2023.11.08
스프링 시큐리티_구글 소셜로그인_DB연결  (0) 2023.11.01
local=> Git  (0) 2023.11.01
파이썬 기초_1  (1) 2023.10.24
파일질라_리눅스_자바서비스_vmware_ftp  (1) 2023.10.06

1. github 리포지토리 생성

2. 로컬에 있는 프로젝트 경로 이동 
cd 프로젝트 경로 

3. git init 명령어로 .git파일 생성 

4. github 리포지토리에 remote 명령어 복사 커맨드 라인 붙여 넣기
git remote add origin https://github.com/cojuns/_gitTest.git

5. git add. 입력

6. git commit -m "first commit" 입력


7. git push origin main이나 master 입력 ( 브랜치 이름에 따라 틀림 )

 

 

 

 

 

 

 

 

 

 

 

 

Git bash

 

'코드 정리' 카테고리의 다른 글

Vue.js 실전_ 연습 순서  (0) 2023.11.08
스프링 시큐리티_구글 소셜로그인_DB연결  (0) 2023.11.01
Vue.js basic  (0) 2023.11.01
파이썬 기초_1  (1) 2023.10.24
파일질라_리눅스_자바서비스_vmware_ftp  (1) 2023.10.06

방법 1 

아나콘다 설치 후 아나콘다 커맨드에서 실행

C:\Users\dojang>jupyter notebook


방법 2 

vscode에서 파이썬 설치 후 

  • Python Package 설치
c:\> pip3 install --upgrade pip

- jupyter 설치

c:\> pip3 install jupyter 
c:\> pip3 install tensorflow

- matlotlib 설치

c:\> pip3 install -U pip setuptools
c:\> pip3 install matplotlib




그래프
import matplotlib.pyplot as plt
plt.plot([1,5,7,3,7])
plt.show()

import matplotlib.pyplot as plt
month = ['mar','apr','may','jun','jul']
sales = [1,5,7,3,7]
plt.plot(month, sales)
plt.show()

import matplotlib.pyplot as plt
month = ['mar','apr','may','jun','jul']
sales = [1,5,7,3,7]
plt.rc('font', family='Malgun Gothic')
plt.title('월별 판매 실적')
#plt.plot(month, sales, color='r')
# plt.bar(range(2,11,2),month, sales, color='g')
plt.barh(range(2,11,2),sales, color='g')
plt.xlabel('월')
plt.ylabel('매출')
plt.show()

# 원 그래프 
import matplotlib.pyplot as plt 
b_type = [25, 19, 37, 11]
plt.rc('font', family='Malgun Gothic')
plt.title('혈액형 비율')
plt.pie(b_type, labels=['A형', 'B형', 'O형', 'AB형'])
plt.show()

# 그래프 2개 표시
import matplotlib.pyplot as plt 
singer = ['A', 'B', 'C', 'D', 'E']
week1 = [42, 58, 19, 92, 84]
week2 = [53, 52, 48, 98, 73]
plt.plot(singer, week1, label="첫째 주", color='hotpink')
plt.plot(singer, week2, label="둘째 주", color='royalblue')
plt.legend()
plt.show()


#tkinter

from tkinter import *
root = Tk()
root.title('나의 첫 tkinter')
root.geometry('400x200+300+300')
label1 = Label(root, text="하이?")
label1.pack()
root.mainloop()



# #tkinter 이미지 ( Toplevel() => Tk() 실행 ) 
import tkinter

root=tkinter.Tk()
# root=tkinter.Toplevel()
root.title("blog")
root.geometry("840x420")
image=tkinter.PhotoImage(file="c:/zzz/1024.png")
label=tkinter.Label(root, image=image)
label.pack()

root.mainloop()

#사용자 정의 

def hi123(name, age=12):
    print('안녕')
    print('My name is', name, ' ', age, '살')
hi123(name='둘리')
hi123(name='둘리', age=23)

def hi123(name, age=12):
    print('안녕')
    print('My name is', name, ' ', age, '살')
    return 'My name is' + name + ' ' + age + '살'
# hi123(name='둘리')
hi123(name='둘리', age=23)
str = hi123(name='둘리', age=23)
print(str)

# 튜플
def hi123(name, age=12, score=0):
    print('안녕')
    etc = 'My name is' + name
    sum = score + 30
    return sum, etc, age

str = hi123('둘리', 14, 67)
print(str)

'코드 정리' 카테고리의 다른 글

Vue.js 실전_ 연습 순서  (0) 2023.11.08
스프링 시큐리티_구글 소셜로그인_DB연결  (0) 2023.11.01
Vue.js basic  (0) 2023.11.01
local=> Git  (0) 2023.11.01
파일질라_리눅스_자바서비스_vmware_ftp  (1) 2023.10.06

+ Recent posts