파이썬을 사용할 때는 Flask라는 서버를 사용한다.
이번 프로젝트를 진행하면서 여러 책과 유튜브, 인터넷으로 공부하면서 진행한 내용을 적어보려고 한다.
먼저 제일 기초인 서버 설정과 html 연결이다.
vscode를 사용하였다.
# 서버 구동
qpp.py
from flask import Flask
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)

# html 연결
- html은 templates 폴더 안에 넣어서 저장한다.
app.py
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def hello_world():
return render_template('a.html')
if __name__ == '__main__':
app.run(host='0.0.0.0', port=5000, debug=True)
a.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
테스트 성공!
</body>
</html>

'Backend' 카테고리의 다른 글
| CK에디터 사용방법 (0) | 2022.05.29 |
|---|---|
| [Nodejs] 구글 API 로그인, 로그아웃 (0) | 2022.03.25 |
| [JSP] JDK / WebServer - Tomcat / 이클립스 설치 (0) | 2021.08.31 |
| [Anaconda] 가상환경 생성 (0) | 2021.08.05 |
| [Node] 서버 생성 (0) | 2021.08.04 |