__init__.py 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. """
  2. Initialize the modules needed for the website
  3. """
  4. import os
  5. from flask import Flask
  6. from flask_sqlalchemy import SQLAlchemy
  7. from flask_migrate import Migrate
  8. from flask_login import LoginManager
  9. from flask_compress import Compress
  10. from flask_argon2 import Argon2
  11. from flask_menu import Menu
  12. from dotenv import load_dotenv
  13. load_dotenv()
  14. class Config(object):
  15. """Flask configuration"""
  16. UPLOAD_FOLDER = 'app/static/uploads'
  17. SCHEDULER_API_ENABLED = True
  18. SQLALCHEMY_DATABASE_URI = os.environ["DATABASE_URI"]
  19. SECRET_KEY = os.environ["SECRET_KEY"]
  20. SQLALCHEMY_TRACK_MODIFICATIONS = False
  21. SEND_FILE_MAX_AGE_DEFAULT = 1296000
  22. app = Flask(__name__)
  23. app.config.from_object(Config())
  24. app.jinja_env.lstrip_blocks = True
  25. app.jinja_env.trim_blocks = True
  26. app.config['TESTING'] = False
  27. # Compress settings
  28. COMPRESS_MIMETYPES = [
  29. 'text/html',
  30. 'text/css',
  31. 'text/xml',
  32. 'application/json',
  33. 'application/javascript'
  34. ]
  35. COMPRESS_LEVEL = 6
  36. COMPRESS_MIN_SIZE = 500
  37. Compress(app)
  38. Menu(app=app)
  39. db = SQLAlchemy(app)
  40. migrate = Migrate(app, db)
  41. argon2 = Argon2(app)
  42. # Login
  43. login_manager = LoginManager()
  44. login_manager.init_app(app)
  45. login_manager.login_view = "auth.login"
  46. login_manager.login_message_category = "warning"