1234567891011121314151617181920 |
- """
- Defines the Flask object used to run the server.
- """
- import os
- from typing import Any
- from flask import Flask
- from flask_sqlalchemy import SQLAlchemy # type: ignore
- DATA_HOME = os.environ.get("XDG_DATA_HOME", "~/.local/share")
- CONFIG_DIR = os.path.join(DATA_HOME, "piket_server")
- DB_PATH = os.path.expanduser(os.path.join(CONFIG_DIR, "database.sqlite3"))
- DB_URL = f"sqlite:///{DB_PATH}"
- app = Flask("piket_server")
- app.config["SQLALCHEMY_DATABASE_URI"] = DB_URL
- app.config["SQLALCHEMY_TRACK_MODIFICATIONS"] = False
- db: Any = SQLAlchemy(app)
|