KISS/kiss/__init__.py

52 lines
842 B
Python
Raw Normal View History

2022-11-17 02:52:37 +00:00
import sys
import click
from flask.cli import FlaskGroup
def init():
global __version__
global app
global ssmanager
import signal
from importlib.metadata import version
from flask import Flask
from kiss.ssmanager import ScreenshotManager
__version__ = version("kiss")
# Initialize App
app = Flask(__name__)
# Screenshot Manager
ssmanager = ScreenshotManager()
# Handle SIGINT
signal.signal(signal.SIGINT, signal_handler)
def signal_handler(sig, frame):
if ssmanager:
ssmanager.stop()
sys.exit(0)
def create_app():
init()
import kiss.api as api_common
app.register_blueprint(api_common.bp)
ssmanager.start()
return app
@click.group(cls=FlaskGroup, create_app=create_app)
def cli():
"""Management script for the application."""