Sphinx documentation inside Flask web application

I created local static Sphinx documentation (using make html ).

Now I want to integrate Sphinx files into my webapp that works with Flask. From the application running Flask, I just want to include a hyperlink to the Sphinx documentation, which will serve as help for the application.

Websupport seems to be a way to follow, but it is not clear to me how I should reduce the flash frame to Sphinx files.

Thanks for any help

Hello

+6
source share
3 answers

You can simply handle it using your web server, just like you handle the /static directory in Flask. For example, if you used Apache as your web server for production, you can add

 Alias /documentation /location/of/sphinx/html <Directory /location/of/sphinx/html> Order deny,allow Allow from all </Directory> 

for your Apache site configuration, so you can simply directly link it to http://yoursite.com/documentation to access Sphinx files, completely avoiding Flask.

+5
source

You can copy the _build/html folder from your documents to the doc folder in the static flags directory and execute them with the following rule:

 @app.route('/doc/<dir>/<filename>', defaults={'static': True}) def doc(dir='',filename='index.html'): path = join(dir,filename) return app.send_static_file(path) 
+2
source

In some cases, you do not want to disclose your documents to all users, so setting up 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/<path:filename>') @login_required def web_docs(filename): path = os.path.join('docs/html', filename) return app.send_static_file(path) 
+1
source

All Articles