flask 프레임워크
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def home():
return render_template('index.html') #templates 폴더 안에 있는 index.html파일을 client에게 전달
@app.route('/mypage')
def mypage():
return 'mypage 입니다.'
if __name__ == '__main__':
app.run('0.0.0.0',port=5000,debug=True)
프레임워크를 사용할 때에는 정해진 규칙을 지켜야 한다.
Flask 서버를 만들 때 프로젝트 폴더 안에 3가지를 생성한다.
static 폴더 : CSS나 image파일을 담아 둘 때 사용
templates 폴더
주의
서버에 요청하여 index.html을 불러와야 한다. index파일을 실행하여 열지 말 것