diff --git a/app/main.py b/app/main.py index a93f0d6..88b8545 100644 --- a/app/main.py +++ b/app/main.py @@ -21,8 +21,7 @@ def checkDeps(): if not MIFARE_APP_MASTER_KEY: logger.critical(f"MIFARE APP MASTER KEY not found!") logger.critical("Writing and reading cards is disabled!") - global disableCards - disableCards = True + @asynccontextmanager async def lifespan(app: FastAPI): @@ -30,7 +29,9 @@ async def lifespan(app: FastAPI): create_db_and_tables() create_first_user(db=get_db_session()) logger.info("Database created and tables initialized.") - scanner.start() + disableCards = os.getenv("DISABLE_CARDS") + if not disableCards: + scanner.start() yield #scanner.stop()