feat: dynamic privacy policy loading
Enhanced the privacy policy display functionality to dynamically load content from a configurable file path. The path is specified via the `STRUCTABLES_PRIVACY_FILE` environment variable, allowing for greater flexibility and easier updates to the privacy policy without needing to redeploy the application. If the specified file is unreachable or the environment variable is unset, the system gracefully falls back to a default message, ensuring the site remains compliant with privacy policy disclosures under various circumstances. This change streamlines content management and improves the adaptability of the application to legal and policy requirements.
This commit is contained in:
parent
2d4df9bae1
commit
9c8c9b6c17
1 changed files with 10 additions and 1 deletions
|
@ -333,10 +333,19 @@ def init_main_routes(app):
|
|||
|
||||
@app.route("/privacypolicy/")
|
||||
def privacypolicy():
|
||||
"""Display the privacy policy.
|
||||
|
||||
The privacy policy is loaded from the file specified in the
|
||||
`STRUCTABLES_PRIVACY_FILE` environment variable. If that variable is
|
||||
unset or the file cannot be read, a default message is displayed.
|
||||
"""
|
||||
|
||||
content = "No privacy policy found."
|
||||
|
||||
path = app.config.get("PRIVACY_FILE", "privacy.txt")
|
||||
|
||||
try:
|
||||
with (pathlib.Path(__file__).parent / "privacy.txt").open() as f:
|
||||
with pathlib.Path(path).open() as f:
|
||||
content = f.read()
|
||||
except OSError:
|
||||
pass
|
||||
|
|
Loading…
Reference in a new issue