-1
자습서를 따라 {Hello World}로 {{test}}를 대체 할 간단한 프로그램을 만들려고합니다.하지만 HTML 파일을 열면 난처하게됩니다. - 'Hello World'대신 페이지에 {{test}}가 표시되어 나타나야합니다.HTML 파일의 텍스트를 변경하는 Python Flask
나는이 문제를 해결하기 위해 무엇을해야할지 잘 모르므로 도움을 얻을 수 있습니다.
두 파일을 연결했는지 여부는 확실하지 않습니다. 지식으로는 동영상에 지정되지 않았기 때문에 두 파일간에 링크가 없다는 사실 만 알았습니다.
파이썬 코드 :
from flask import Flask, render_template
app = Flask(__name__)
@app.route('/')
def homepage():
return render_template('index.html', test='hello world')
if __name__ == '__main__':
homepage()
else:
print('Please run this file as main, not as module.')
HTML 코드 :
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<p> {{ test }} </p>
</body>
</html>