我正在通过Flask框架实现一个Web应用程序。这个网络应用程序即将服务器静态HTML页面,其结构是像Java文档。Flask提供静态html页面
代码:
从烧瓶进口烧瓶中,send_from_directory,url_for
app = Flask(__name__)
@app.route("/")
def hello():
return "Hello World!"
@app.route("/report")
def view_report():
url_for('static', filename='report/flexmonkey/html/')
return send_from_directory('static', 'report/flexmonkey/html/index.html')
if __name__ == "__main__":
app.run(debug=True)
中的index.html:
Unit Test Results.Frame Alert
This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client.
目录结构:
~/workspace/testReport/static/report/flexmonkey/html $ ls
allclasses-frame.ht

本文介绍了如何使用Flask框架为Web应用提供静态HTML页面。在实现过程中,遇到了通过`send_from_directory`和`url_for`跳转到静态页面时出现404错误的问题。目录结构和部分代码被展示出来,讨论了可能的解决方案,即检查`send_from_directory`中的路径是否正确,可能是相对路径导致的问题。
最低0.47元/天 解锁文章

1193

被折叠的 条评论
为什么被折叠?



