Python烧瓶未显示HTML文件
我正在使用一个由各种工作细节组成的JSON文件。这个JSON文件在我的存储库中,所以我正在使用 响应= requests.get('https://github.com/myname/beatifle-soup/blob/main/jsonfile.json')
我必须将此响应转换为JSON文件才能显示这些工作详细信息在我的HTML文件上。我设置了烧瓶环境,除了某种原因,我的HTML文件未显示任何信息。我该如何解决?
以下是我的python,html
import json
import requests
from flask import Flask, render_template
# write a code to give call to json file and then render
# html page
app = Flask(__name__)
@app.route("/")
def displayJobDetails():
response = requests.get('https://github.com/myName/Beatiful-Soup/blob/main/jsonFile.json')
data = json.loads(response.text);
return render_template('index.html', message="data")
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000, debug=True)
<!DOCTYPE html>
<html>
<head>
<title>Display the Job Details</title>
</head>
<body>
<div>
<p> {{ message }}} </p>
</div>
</body>
</html>
我的网页仅显示{{messages}}
I am using a JSON file that consists of various job details. This JSON file is in my repository so I am usingresponse = requests.get('https://github.com/myname/Beatiful-Soup/blob/main/jsonFile.json')
I have to convert this response to JSON file in order to display these job details on my HTML file. I set up the flask environment and everything but by some reason my HTML file not displaying any information. How could I fix that?
below is my Python, and HTML
import json
import requests
from flask import Flask, render_template
# write a code to give call to json file and then render
# html page
app = Flask(__name__)
@app.route("/")
def displayJobDetails():
response = requests.get('https://github.com/myName/Beatiful-Soup/blob/main/jsonFile.json')
data = json.loads(response.text);
return render_template('index.html', message="data")
if __name__ == '__main__':
app.run(host='0.0.0.0', port=8000, debug=True)
<!DOCTYPE html>
<html>
<head>
<title>Display the Job Details</title>
</head>
<body>
<div>
<p> {{ message }}} </p>
</div>
</body>
</html>
my webpage displays only {{message}}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将消息设置为字符串,而不是您的实际数据。尝试以下操作:
You are setting message to a string, not your actual data. Try this: