python, html, flask 질문!!!!

조회수 545회

라즈베리4 파이썬에서 미세먼지센서를 작동시켰습니다.

@app.route("/", methods=["GET"])
def test():
    dustdata = 'dust3()'
    return render_template("index.html", dusthtml=dustdata)

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

html에서 어떻게 바꿔야 저 dust3()라는 함수의 값을 html에 넘겨줄수 있나요?

<DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>dust test</title>
    <meta http-equiv="refresh" content="3">
</head>
<body>
    <div class="container">
        <div class="header">
            dust= {[dusthtml]};
        </div>
    </div>
</body>
</html>

원하는 작동은 dust = ????라고 뜨는것입니다.

이미지

어떻게 해야 dust값을 파이썬에서 가져올수가있나요? 부탁드립니다.

  • {{ }} 로 감싸세요 관련되어서 flask - jinja2 template 검색하시면 정보 많이 나옵니당 김호원 2021.7.12 16:20

답변을 하려면 로그인이 필요합니다.

프로그래머스 커뮤니티는 개발자들을 위한 Q&A 서비스입니다. 로그인해야 답변을 작성하실 수 있습니다.

(ಠ_ಠ)
(ಠ‿ಠ)