树莓派上的Sphinx文档无法访问html

时间:2018-10-04 07:17:04

标签: python python-3.x flask python-sphinx

我正在按照本教程https://projects.raspberrypi.org/en/projects/documenting-your-code/7

为树莓派创建Sphinx文档。

Sphinx生成了一些html页面,当我使用Flask时,我希望能够通过该路径从我的应用程序主页访问该页面。

例如,这将是app.py

中的一条路线
@APP.route("/docs")
def docspage():
    return render_template('docs/index.html', title='Docs')

和我的layout.html

<a class="nav-link" href="{{ url_for('docspage') }}">Docs</a>

我遇到的问题是,只有在templates文件夹中的情况下,才能访问Flask中的html文件。通过sphinx生成文档会创建一个名为_build的文件夹,该文件夹不在模板内。

我尝试将_build_文件夹移到templates内,但这造成了许多问题,而且似乎_build也是正确的做法,因为{{1}}还包含许多非HTML文件。

使用Flask时,为文档页面设置路由的正确方法是什么?

0 个答案:

没有答案
相关问题