app.py 761 B

1234567891011121314151617181920212223242526272829303132
  1. """
  2. Serve static content
  3. """
  4. import os
  5. from flask import render_template, Blueprint, abort
  6. from jinja2 import TemplateNotFound
  7. from flask_login import current_user
  8. BLUEPRINT = Blueprint(
  9. "static",
  10. __name__,
  11. template_folder='pages'
  12. )
  13. @BLUEPRINT.route("/", defaults={"page": "index"})
  14. @BLUEPRINT.route("/<path:page>")
  15. def show(page):
  16. """Display static page"""
  17. if current_user.is_authenticated:
  18. try:
  19. return render_template("private/%s.html" % page)
  20. except TemplateNotFound:
  21. abort(404)
  22. try:
  23. return render_template("public/%s.html" % page)
  24. except TemplateNotFound:
  25. if os.path.exists("app/modules/static/pages/private/%s.html" % page):
  26. abort(401)
  27. abort(404)