【发布时间】:2019-05-19 22:07:41
【问题描述】:
html页面上的当前json视图
{"result": [{"id": "103300640", "sms_phone": "730276061", "corrected to":
"27730276061"}, {"id": "103277733", "sms_phone": "716125197", "corrected
to": "27716125197"}]}
我希望它被格式化显示为
{
"result":[
{
"id":"103300640",
"sms_phone":"730276061",
"corrected to":"27730276061"
},
{
"id":"103277733",
"sms_phone":"716125197",
"corrected to":"27716125197"
}]
}
JS代码:
@app.route('/<path:req_path>')
def dir_listing(req_path):
abs_path = os.path.join(UPLOAD_FOLDER, req_path)
# Check if path is a file and serve
if os.path.isfile(abs_path):
return send_file(abs_path, mimetype="application/json")
return render_template('/index.html')
HTML 代码:
<ul>
{% for file in file_list %}
<li><a href="{{ file }}" id="list">{{ file }}</a></li>
{% endfor %}
</ul>
【问题讨论】:
-
所以你只想格式化json?
-
我相信其他类似问题已经回答了这个问题。你可能想看看这个one。
-
这对我没有帮助。我在 html 页面上列出了 json 文件,用户点击它应该打开美化的 json 格式。