Digitale bierlijst

flask.py 550B

1234567891011121314151617181920
  1. """
  2. Defines the Flask object used to run the server.
  3. """
  4. import os
  5. from typing import Any
  6. from flask import Flask
  7. from flask_sqlalchemy import SQLAlchemy # type: ignore
  8. DATA_HOME = os.environ.get("XDG_DATA_HOME", "~/.local/share")
  9. CONFIG_DIR = os.path.join(DATA_HOME, "piket_server")
  10. DB_PATH = os.path.expanduser(os.path.join(CONFIG_DIR, "database.sqlite3"))
  11. DB_URL = f"sqlite:///{DB_PATH}"
  12. app = Flask("piket_server")
  13. app.config["SQLALCHEMY_DATABASE_URI"] = DB_URL
  14. app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
  15. db: Any = SQLAlchemy(app)