python - Flask render_template() 不会渲染 xhtml,但是当我手动打开它时它会在我的浏览器中正确渲染
问题描述
我正在尝试渲染 xhtml (X3D) 文件。问题是,当通过烧瓶路线渲染这些模板时,一个 xhtml 模板可以正常工作,而另一个不能。当我在浏览器中手动打开它们时,这两个文件都可以正常工作。第二个文件是使用 BeautifulSoup 对第一个文件的修改。
#flask app module
from flask import Flask, render_template
app = Flask(__name__)
@app.route("/")
def hello_world():
return render_template('index.html')
@app.route('/xhtml')
def xhtml():
return render_template('8b0e87efd5144053916a1cadfc9c5194.xhtml')
@app.route('/xhtml_2')
def xhtml_2():
return render_template('920e053d8e474fc1869e9a2c763e9186.xhtml')
if __name__ == '__main__':
app.run(debug=True)
关于 render_template() 我有什么遗漏吗?
解决方案
这两个文件非常相似,因为第二个文件只是使用 BeatifulSoup 对第一个文件的修改。我玩弄了这些文件并逐步更改了代码块。我想通了,BeautifulSoup 变了
<Viewpoint ... ></Viewpoint>
至
<Viewpoint ... />
jinja 似乎不喜欢它。更改损坏文件中的这些标签后,它现在可以正确呈现:
<Viewpoint ... > </Viewpoint>
即使没有人能为我解决这个问题,我仍然感谢您的意见,因为它让我更加专注地思考我的问题。
推荐阅读
- ios - 迅速; 单击推送通知而不打开应用程序时如何打开Safari?
- reactjs - 访问子组件的值
- linux - 命令在终端中运行,但不在 bash 脚本中
- javascript - 我无法理解错误是什么,因为我做的一切都是正确的
- python - 在 django 中创建自定义模板标签
- php - 连接到 nginx+php-fpm docker 的上游时,connect() 失败(111:连接被拒绝)
- php - 基于多字段搜索返回行
- c++ - 来自 QAbstractVideoSurface 的 QT QLabel setPixmap
- android-studio - 意图加载的 URL 没有响应 Android Studio
- java - JavaFX ColorPicker 自定义颜色选择器显示在窗口后面