콘텐츠로 이동

44. index.html 템플릿 랜더링 연습

Video

준비 중

Note

코드 자료

templates 폴더를 생성 후 안에 index.html 파일을 아래와 같이 작성

templates/index.html
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{ title }}</title>
</head>
<body>
<h1>{{ title }}</h1>
<h2> Hello!!</h2>
</body>
</html>

test.py
from flask import Flask, render_template

app = Flask(__name__)

@app.route("/")
def index():
    title = "OpenAI API Agent School" 
    return render_template('index.html', title=title)

if __name__ == "__main__":
    app.run(host="0.0.0.0")

Resources