티스토리 뷰



일단 pip를 이용해 flask를 설치한다. 

아래와 같은 코드를 돌리면 hello.html 파일을 게시할 수 있다. 다만 이 html파일은 templates라는 서브 폴더 안에 들어가 있어야 한다. 

ip주소:5000으로 웹브라우저에서 돌리면 hello.html파일을 볼 수 있다. 


from flask import Flask, render_template

app = Flask(__name__)


@app.route("/")

def hello():

return render_template('hello.html')


if __name__ == "__main__":

    app.run(host='0.0.0.0', port=5000, debug=True) 



댓글
최근에 올라온 글
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함
Total
Today
Yesterday