본문 바로가기

카테고리 없음

Flask시작하기 - HTML파일 주기

[index.html 코드]

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
</head>
<body>
하나만 입력해 봅시다.
</body>
</html>

 

 

 

[app.py코드]

from flask import Flask, render_template
app = Flask(__name__)

@app.route('/')
def home():
return render_template('index.html')

if __name__ == '__main__':
app.run('0.0.0.0',port=5000,debug=True)

  • http://localhost:5000/

 

  • 순서
  • [ index.html ] → [ app.py ] → ▶run 'app' http://localhost:5000/ttp

[ index.html ] 예제코드

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<title>Document</title>
</head>
<body>
<h1>서버를 만들었다!</h1>
</body>
</html>

  • http://localhost:5000 새로고침