from flask_app import FlaskApplication


class MainApplication(FlaskApplication):
    
    def __init__(self) -> None:
        super().__init__()

    def run(self, port):
        try:
            # Load the configuration using the default values 
            self.app = self.create_app() 

            if self.debug:
                self.app.logger.info('DEBUG       = ' + str(self.debug))
                self.app.logger.info('Environment = ' + self.config_mode)
            self.app.run(debug=True if self.debug else False, host="0.0.0.0", port=port)
            # app.run(self.app, debug=True, host="0.0.0.0", port=port)

        except KeyError:
            exit('Error: Invalid <config_mode>. Expected values [Debug, Production] ')

