Sphinx documentation inside a Flask running web application

后端 未结 4 1776
隐瞒了意图╮
隐瞒了意图╮ 2021-02-13 04:40

I\'ve locally built static Sphinx documentations (using make html).

I wish now to integrate the Sphinx files into my webapp that runs with Flask. From the

4条回答
  •  遥遥无期
    2021-02-13 05:05

    In some cases you do not want to expose your docs to all users so configuring at the Apache or Nginx level is not an option. The following worked for me:

    @app.route('/docs', defaults = {'filename': 'index.html'})
    @app.route('/docs/')
    @login_required
    def web_docs(filename):
        path = os.path.join('docs/html', filename)
        return app.send_static_file(path)
    

提交回复
热议问题