flask静态html跳转页面,Flask提供静态html页面

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

我正在通过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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
>