from __future__ import annotations
import logging,os
from flask import Flask
from admin import config
from admin.models import db
logging.basicConfig(level=logging.INFO)
def create_app():
	C='WATCHER_STARTED';B=True;A=Flask(__name__,template_folder='templates',static_folder='static');A.secret_key=config.SECRET_KEY;config.DATA_ROOT.mkdir(parents=B,exist_ok=B);config.APPS_ROOT.mkdir(parents=B,exist_ok=B);config.RELEASES_ROOT.mkdir(parents=B,exist_ok=B);db.init();from admin.routes import bp;A.register_blueprint(bp);D=os.environ.get('WERKZEUG_RUN_MAIN')=='true'
	if(not A.debug or D)and not A.config.get(C):from admin.services.watcher import start_watcher as E;E(A);A.config[C]=B
	return A
app=create_app()
