-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new: [website] New optional blueprint able to serve the static HTML f…
…iles generated by Sphinx for the documentation of Vulnerability-Lookup.
- Loading branch information
1 parent
915f08f
commit e27ac9f
Showing
3 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python3 | ||
|
||
from flask import abort | ||
from flask import Blueprint | ||
from flask import send_from_directory | ||
from werkzeug import Response as WerkzeugResponse | ||
|
||
from vulnerabilitylookup.default import get_homedir | ||
|
||
# Define the blueprint | ||
homedir = get_homedir() | ||
static_folder = homedir.joinpath("docs/_build/html") | ||
documentation_bp = Blueprint('documentation', __name__, url_prefix="/documentation", static_folder=static_folder) | ||
|
||
|
||
@documentation_bp.route('/<path:filename>') | ||
def serve_documentation(filename: str) -> WerkzeugResponse: | ||
"""Serve static files from the Sphinx build folder.""" | ||
if None is documentation_bp.static_folder: | ||
return abort(404) | ||
return send_from_directory(documentation_bp.static_folder, filename) | ||
|
||
|
||
@documentation_bp.route('/') | ||
def serve_index() -> WerkzeugResponse: | ||
"""Redirect `/documentation` to `/documentation/index.html`""" | ||
if None is documentation_bp.static_folder: | ||
return abort(404) | ||
return send_from_directory(documentation_bp.static_folder, 'index.html') |