flaskr.py 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. """
  2. Simple flask thing
  3. """
  4. from flask import redirect, flash, render_template
  5. from app import app
  6. from app.modules.static import Static
  7. from app.modules.backend import Backend
  8. from app.modules.auth import Auth
  9. from app.modules.vote import Vote
  10. from app.modules.backend.modules.page import Backend_Page
  11. from app.modules.backend.modules.file import Backend_File
  12. from app.modules.backend.modules.user import Backend_User
  13. from app.modules.backend.modules.vote import Backend_Vote
  14. app.register_blueprint(Auth)
  15. app.register_blueprint(Static)
  16. app.register_blueprint(Backend, url_prefix='/backend')
  17. app.register_blueprint(Backend_Page, url_prefix='/backend/page')
  18. app.register_blueprint(Backend_File, url_prefix='/backend/file')
  19. app.register_blueprint(Backend_User, url_prefix='/backend/user')
  20. app.register_blueprint(Backend_Vote, url_prefix='/backend/vote')
  21. app.register_blueprint(Vote, url_prefix='/vote')
  22. @app.errorhandler(404)
  23. def page_not_found(error):
  24. return render_template("error/404.html")
  25. @app.errorhandler(401)
  26. def login_required(error):
  27. flash('Please login before opening page', 'warning')
  28. return redirect('/login', code=302)