37 lines
997 B
Python
37 lines
997 B
Python
import os
|
|
from typing import Any
|
|
|
|
from flask import Flask
|
|
|
|
from starfall.config import Config
|
|
from starfall.db import db
|
|
from starfall.web.home import home_blueprint
|
|
|
|
|
|
class App:
|
|
app: Flask = Flask(__name__)
|
|
config: dict[str, Any] = dict() # pyright: ignore[reportExplicitAny]
|
|
|
|
@classmethod
|
|
def __init__(cls):
|
|
cls.load_config()
|
|
cls.app.config.update( # pyright: ignore[reportUnknownMemberType]
|
|
SECRET_KEY=cls.config.get("secret_key"),
|
|
SQLALCHEMY_DATABASE_URI=cls.config.get("database_url"),
|
|
)
|
|
|
|
cls.app.root_path = os.path.realpath(".")
|
|
cls.app.static_folder = os.path.realpath("./web/static")
|
|
cls.app.template_folder = "web"
|
|
|
|
db.init_app(cls.app)
|
|
cls.app.register_blueprint(home_blueprint)
|
|
|
|
@classmethod
|
|
def load_config(cls):
|
|
cls.config = Config.get("web", {})
|
|
|
|
@classmethod
|
|
def run(cls):
|
|
cls.app.run(host=cls.config.get("host"), port=cls.config.get("port"))
|