support-organizer/backend/fgo_request_manager/app.py
Firq 03901e1d12
All checks were successful
/ build:package (push) Successful in 11s
/ backend-pylint (push) Successful in 21s
updated package to conform to pylint
2023-12-21 17:11:47 +01:00

38 lines
937 B
Python

# pylint: disable=too-few-public-methods
from datetime import datetime
from flask import Flask
from flask_smorest import Api
from .config import APISettings
class IsSingletonException(Exception):
pass
class Application:
"""
This is a singleton that can be accessed using get_instance()
It has 2 properties
- app: Used for WSGI servers and such
- api: Used for Blueprints
"""
__instance = None
app = Flask(__name__)
app.config.from_object(APISettings)
api = None
alive_since = None
@staticmethod
def get_instance():
if Application.__instance is None:
Application()
return Application.__instance
def __init__(self):
if Application.__instance is not None:
raise IsSingletonException("This class is a singleton")
Application.__instance = self
self.api = Api(self.app)
self.alive_since = datetime.now()