SlideShare a Scribd company logo
1 of 34
Download to read offline
서버그리고데이터베이스
나만의블로그개발해보기
02
Front-end
우리가실제로보는부분들
Back-end
보이지는않지만서비스가
돌아가는데필요한부분들
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
1
URL이랑나를받아라
2
ㅇㅎㅇㅋㅇㅋㄱㄷ
3
받아서띄운다~
요함수에는요걸보여줘야함HTML보낸다일해라
서버로데이터보내고띄우기
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
데이터를보내는방법
GET
POST
데이터를달라고요청한다
ex)일반적인웹사이트들어갈때
데이터를보낸다
ex)게시물올리기,로그인등
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
서버로데이터를보낼때쓰는
<form>과친구들
<input>
<textarea>
…
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
1
2
3
4
<form method=“GET” action=“/method_check”>
<input type=“text” name=“name” placeholder=“이름”>
<input type=“submit”>
</form>
보내는방식(GET/POST) 어느주소로보낼껀지
데이터를받을때혼란이오지않게
이름을붙이고끝은항상submit달기
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
웹서비스만들기 with
파일하나로기본적인기능을제공함
필요한게있으면그때그때pip로추가
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
오늘의작업
templates
아래와같은폴더/파일을만들어작업해보겠습니다
* learn_flask폴더명은“flask”로만안한다면마음대로바꿔도됩니다.
* 나머지폴더명은바꾸면안됩니다.
learn_flask
app.py
index.html
1
2
3
4
5
6
7
8
9
10
from flask import Flask
import sys
app = Flask(__name__)
@app.route(“/”)
def hello():
return “Hello World!”
if __name__ == “__main__”:
app.run()
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
learn_flask/app.py
1
2
3
4
5
6
7
8
9
10
from flask import Flask
import sys
app = Flask(__name__)
@app.route(“/”)
def hello():
return “Hello World!”
if __name__ == “__main__”:
app.run()
from flask import Flask
app = Flask(__name__)
Flask라는클래스를가져온다.
Flask객체를하나만듭니다.
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
@app.route(“/”)
def hello():
return “Hello World!”
1
2
3
4
5
6
7
8
9
10
from flask import Flask
import sys
app = Flask(__name__)
@app.route(“/”)
def hello():
return “Hello World!”
if __name__ == “__main__”:
app.run()
/라는주소로라우팅(주소설정)한다.
해당하는URL이오면hello()함수를실행한다.
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
@app.route(“/”)
def hello():
return “<html><body><h1>Hello World!</h1></body></html>”
1
2
3
4
5
6
7
8
9
10
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
1
2
3
4
5
6
7
8
9
10
11
12
from flask import Flask
from flask import render_template
from flask import request
import sys
app = Flask(__name__)
@app.route(“/”)
def hello():
return render_template(“index.html”)
if __name__ == “__main__”:
app.run()
from flask import render_template /HTML을보여주기위한
템플릿엔진클래스를가져옵니다.
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
1
2
3
4
5
6
7
8
9
10
11
12
from flask import Flask
from flask import render_template
from flask import request
import sys
app = Flask(__name__)
@app.route(“/”)
def hello():
return render_template(“index.html”)
if __name__ == “__main__”:
app.run()
return render_template(“index.html”) /templates폴더안에있는
html파일을불러옵니다.
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
1
2
3
4
<form method=“GET” action=“/method_check”>
<input type=“text” name=“name” placeholder=“이름”>
<input type=“submit”>
</form>
@app.route(“/method_check”)
def get_method():
return “Hello, Mr, %s?” % (request.args[‘name’])
1
2
3
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
learn_flask/templates/index.html
learn_flask/app.py에 추가
1
2
3
4
<form method=“POST” action=“/post_check”>
<input type=“text” name=“name” placeholder=“이름”>
<input type=“submit”>
</form>
@app.route(“/post_check”, methods=[‘POST’])
def post_method():
return “POST로 보냈습니다. %s씨?” % (request.form[‘name’])
1
2
3
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
learn_flask/templates/index.html에 추가
learn_flask/app.py에 추가
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
from flask import Flask
from flask import render_template
from flask import request
import sys
app = Flask(__name__)
@app.route(“/”)
def hello():
return render_template(“index.html”)
@app.route(“/method_check”)
def get_method():
return “Hello, Mr, %s?” % (request.args[‘name’])
if __name__ == “__main__”:
app.run()
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
근데…데이터는어떻게저장하지?
데이터베이스를써보자!
여러사람들이정보를공유하고사용할목적으로통합적으로관리하는정보의집합
데이터베이스
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
여러사람들이정보를공유하고사용할목적으로통합적으로관리하는정보의집합
데이터베이스
데이터들이통합적으로관리되는곳
SQL이라는언어를사용함
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
지난이야기 그래서오늘은 form이필요해! 구름타고 Flask
SQL의기본
Create Read Update Delete
생성 읽기 갱신 삭제
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
지난이야기 그래서오늘은 form이필요해! 구름타고 Flask
SQL의기본
INSERT SELECT UPDATE DELETE
생성 읽기 갱신 삭제
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
SQL의기본
(CRUD) (column) FROM (table);
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
id name age username
1 이찬희 63 hiddenest
2 김효준 33 retail3210
3 배주웅 25 tamigun.root
4 홍병수 16 frostornge
5 신원준 19 identity0930
6 양기현 22 dexteristan
7 김준성 21 codertimo
8 곽민석 19 kms0730
9 박주찬 20 jcpark210
tablename:user
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
id name age username
1 이찬희 63 hiddenest
2 김효준 33 retail3210
3 배주웅 25 tamigun.root
4 홍병수 16 frostornge
5 신원준 19 identity0930
6 양기현 22 dexteristan
7 김준성 21 codertimo
8 곽민석 19 kms0730
9 박주찬 20 jcpark210
Row
Columntablename:user
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
id name age username
1 이찬희 63 hiddenest
2 김효준 33 retail3210
3 배주웅 25 tamigun.root
4 홍병수 16 frostornge
5 신원준 19 identity0930
6 양기현 22 dexteristan
7 김준성 21 codertimo
8 곽민석 19 kms0730
9 박주찬 20 jcpark210
mysql> SELECT * FROM user;
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
mysql>
id name age username
1 이찬희 63 hiddenest
2 김효준 33 retail3210
3 배주웅 25 tamigun.root
4 홍병수 16 frostornge
5 신원준 19 identity0930
6 양기현 22 dexteristan
7 김준성 21 codertimo
8 곽민석 19 kms0730
9 박주찬 20 jcpark210
SELECT name FROM user;
name
이찬희
김효준
배주웅
홍병수
신원준
양기현
김준성
곽민석
박주찬
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
mysql>
id name age username
1 이찬희 63 hiddenest
2 김효준 33 retail3210
3 배주웅 25 tamigun.root
4 홍병수 16 frostornge
5 신원준 19 identity0930
6 양기현 22 dexteristan
7 김준성 21 codertimo
8 곽민석 19 kms0730
9 박주찬 20 jcpark210
SELECT * FROM user WHERE name=“배주웅”
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
3 배주웅 25 tamigun.root
id name age username
mysql>
id name age username
1 이찬희 63 hiddenest
2 김효준 33 retail3210
3 배주웅 25 tamigun.root
4 홍병수 16 frostornge
5 신원준 19 identity0930
6 양기현 22 dexteristan
7 김준성 21 codertimo
8 곽민석 19 kms0730
9 박주찬 20 jcpark210
SELECT * FROM user WHERE age > 30;
지난이야기 오늘의수업 <form>이필요해 Flask로코딩하기 데이터저장하기
id name age username
1 이찬희 63 hiddenest
2 김효준 33 retail3210
백견이불여일코딩
백번보는것이코딩한번하는것보다못하다
감사합니다!
글쓰고읽기,쓴글의리스트보기
수업때만나요:)

More Related Content

Featured

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTExpeed Software
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsPixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 

Featured (20)

Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 

[나만의블로그개발하기] 02 서버 그리고 데이터베이스