///
Search
👖

06.(211126)Flask HTML 출력하기

폴더 구조
app.run()안에 호스트와 포트번호를 넣어주는게 키포인트

main.py

from flask import Flask, render_template import os app = Flask(__name__) @app.route('/') def index(): return render_template('index.html') if __name__ == '__main__': # Flask 서비스 스타트 app.run(host='0.0.0.0', port=8000, debug=True)
Python
복사

templates/index.html

<!doctype html> <html> <head> This is Main page Head<br> </head> <body> This is Main Page Body<br> And This is Accepted Data </body> </html>
HTML
복사

컴파일 명령어

python main.py

실행화면