
import os
import inspect
import logging
from logging.handlers import TimedRotatingFileHandler

from flask import Flask
from flask_cors import CORS

from src.api.endpoints.ns_move import api as ns5
from src.api.endpoints.ns_browse import api as ns6
from src.api.endpoints.ns_trash import api as ns7
from src.api.endpoints.ns_preview import api as ns8
from src.api.endpoints.ns_init import api as ns9

from src.api.restplus import api
import settings

################################################################################
# SETUP LOGGING
################################################################################

pathToThisPyFile = inspect.getfile(inspect.currentframe())
path, filename = os.path.split(pathToThisPyFile)
filename = os.path.splitext(filename)[0] + '.log'
log_folder_path = os.path.join(path, 'logs')
if not os.path.exists(log_folder_path):
    os.mkdir(log_folder_path)
log_path = os.path.join(log_folder_path, filename)

format_string = '%(asctime)s - [%(levelname)s] %(name)s [%(module)s, line %(lineno)d]: %(message)s'

# set up logging to file
logging.basicConfig(level=logging.DEBUG,
                    format=format_string,
                    datefmt='%Y-%m-%d %H:%M')

# set a format which is simpler for console use
formatter = logging.Formatter(format_string)

# define handler
file_log = TimedRotatingFileHandler(log_path, when='W6')
file_log.setLevel(logging.DEBUG)
file_log.setFormatter(formatter)

# add the handlers to the root logger
logging.getLogger().addHandler(file_log)

log = logging.getLogger(__name__)

################################################################################
# SETUP FLASK
################################################################################

app = Flask(__name__)


def configure_app(flask_app):
    # flask_app.config['SERVER_NAME'] = settings.FLASK_SERVER_NAME
    flask_app.config['SWAGGER_UI_DOC_EXPANSION'] = settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION
    flask_app.config['RESTPLUS_VALIDATE'] = settings.RESTPLUS_VALIDATE
    flask_app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
    flask_app.config['ERROR_404_HELP'] = settings.RESTPLUS_ERROR_404_HELP


def initialize_app(flask_app):
    CORS(app)
    configure_app(flask_app)

    api.add_namespace(ns5)
    api.add_namespace(ns6)
    api.add_namespace(ns7)
    api.add_namespace(ns8)
    api.add_namespace(ns9)


def main():

    log.info("================================================================")
    log.info("INITIALISING APP")
    log.info("================================================================")
    initialize_app(app)
    api.init_app(app)
    app.run(debug=settings.API_FLASK_DEBUG, host=settings.API_FLASK_SERVER_HOST, port=settings.API_FLASK_SERVER_PORT)


if __name__ == "__main__":
    main()

    # TODO: check all important settings exist and have valid values



804f17d3fc2448cc660e74b8259e006ff781555a
<mask token>


def configure_app(flask_app):
    flask_app.config['SWAGGER_UI_DOC_EXPANSION'
        ] = settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION
    flask_app.config['RESTPLUS_VALIDATE'] = settings.RESTPLUS_VALIDATE
    flask_app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
    flask_app.config['ERROR_404_HELP'] = settings.RESTPLUS_ERROR_404_HELP


def initialize_app(flask_app):
    CORS(app)
    configure_app(flask_app)
    api.add_namespace(ns5)
    api.add_namespace(ns6)
    api.add_namespace(ns7)
    api.add_namespace(ns8)
    api.add_namespace(ns9)


def main():
    log.info('================================================================'
        )
    log.info('INITIALISING APP')
    log.info('================================================================'
        )
    initialize_app(app)
    api.init_app(app)
    app.run(debug=settings.API_FLASK_DEBUG, host=settings.
        API_FLASK_SERVER_HOST, port=settings.API_FLASK_SERVER_PORT)


<mask token>

<mask token>
if not os.path.exists(log_folder_path):
    os.mkdir(log_folder_path)
<mask token>
logging.basicConfig(level=logging.DEBUG, format=format_string, datefmt=
    '%Y-%m-%d %H:%M')
<mask token>
file_log.setLevel(logging.DEBUG)
file_log.setFormatter(formatter)
logging.getLogger().addHandler(file_log)
<mask token>


def configure_app(flask_app):
    flask_app.config['SWAGGER_UI_DOC_EXPANSION'
        ] = settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION
    flask_app.config['RESTPLUS_VALIDATE'] = settings.RESTPLUS_VALIDATE
    flask_app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
    flask_app.config['ERROR_404_HELP'] = settings.RESTPLUS_ERROR_404_HELP


def initialize_app(flask_app):
    CORS(app)
    configure_app(flask_app)
    api.add_namespace(ns5)
    api.add_namespace(ns6)
    api.add_namespace(ns7)
    api.add_namespace(ns8)
    api.add_namespace(ns9)


def main():
    log.info('================================================================'
        )
    log.info('INITIALISING APP')
    log.info('================================================================'
        )
    initialize_app(app)
    api.init_app(app)
    app.run(debug=settings.API_FLASK_DEBUG, host=settings.
        API_FLASK_SERVER_HOST, port=settings.API_FLASK_SERVER_PORT)


if __name__ == '__main__':
    main()

<mask token>
pathToThisPyFile = inspect.getfile(inspect.currentframe())
path, filename = os.path.split(pathToThisPyFile)
filename = os.path.splitext(filename)[0] + '.log'
log_folder_path = os.path.join(path, 'logs')
if not os.path.exists(log_folder_path):
    os.mkdir(log_folder_path)
log_path = os.path.join(log_folder_path, filename)
format_string = (
    '%(asctime)s - [%(levelname)s] %(name)s [%(module)s, line %(lineno)d]: %(message)s'
    )
logging.basicConfig(level=logging.DEBUG, format=format_string, datefmt=
    '%Y-%m-%d %H:%M')
formatter = logging.Formatter(format_string)
file_log = TimedRotatingFileHandler(log_path, when='W6')
file_log.setLevel(logging.DEBUG)
file_log.setFormatter(formatter)
logging.getLogger().addHandler(file_log)
log = logging.getLogger(__name__)
app = Flask(__name__)


def configure_app(flask_app):
    flask_app.config['SWAGGER_UI_DOC_EXPANSION'
        ] = settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION
    flask_app.config['RESTPLUS_VALIDATE'] = settings.RESTPLUS_VALIDATE
    flask_app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
    flask_app.config['ERROR_404_HELP'] = settings.RESTPLUS_ERROR_404_HELP


def initialize_app(flask_app):
    CORS(app)
    configure_app(flask_app)
    api.add_namespace(ns5)
    api.add_namespace(ns6)
    api.add_namespace(ns7)
    api.add_namespace(ns8)
    api.add_namespace(ns9)


def main():
    log.info('================================================================'
        )
    log.info('INITIALISING APP')
    log.info('================================================================'
        )
    initialize_app(app)
    api.init_app(app)
    app.run(debug=settings.API_FLASK_DEBUG, host=settings.
        API_FLASK_SERVER_HOST, port=settings.API_FLASK_SERVER_PORT)


if __name__ == '__main__':
    main()

import os
import inspect
import logging
from logging.handlers import TimedRotatingFileHandler
from flask import Flask
from flask_cors import CORS
from src.api.endpoints.ns_move import api as ns5
from src.api.endpoints.ns_browse import api as ns6
from src.api.endpoints.ns_trash import api as ns7
from src.api.endpoints.ns_preview import api as ns8
from src.api.endpoints.ns_init import api as ns9
from src.api.restplus import api
import settings
pathToThisPyFile = inspect.getfile(inspect.currentframe())
path, filename = os.path.split(pathToThisPyFile)
filename = os.path.splitext(filename)[0] + '.log'
log_folder_path = os.path.join(path, 'logs')
if not os.path.exists(log_folder_path):
    os.mkdir(log_folder_path)
log_path = os.path.join(log_folder_path, filename)
format_string = (
    '%(asctime)s - [%(levelname)s] %(name)s [%(module)s, line %(lineno)d]: %(message)s'
    )
logging.basicConfig(level=logging.DEBUG, format=format_string, datefmt=
    '%Y-%m-%d %H:%M')
formatter = logging.Formatter(format_string)
file_log = TimedRotatingFileHandler(log_path, when='W6')
file_log.setLevel(logging.DEBUG)
file_log.setFormatter(formatter)
logging.getLogger().addHandler(file_log)
log = logging.getLogger(__name__)
app = Flask(__name__)


def configure_app(flask_app):
    flask_app.config['SWAGGER_UI_DOC_EXPANSION'
        ] = settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION
    flask_app.config['RESTPLUS_VALIDATE'] = settings.RESTPLUS_VALIDATE
    flask_app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
    flask_app.config['ERROR_404_HELP'] = settings.RESTPLUS_ERROR_404_HELP


def initialize_app(flask_app):
    CORS(app)
    configure_app(flask_app)
    api.add_namespace(ns5)
    api.add_namespace(ns6)
    api.add_namespace(ns7)
    api.add_namespace(ns8)
    api.add_namespace(ns9)


def main():
    log.info('================================================================'
        )
    log.info('INITIALISING APP')
    log.info('================================================================'
        )
    initialize_app(app)
    api.init_app(app)
    app.run(debug=settings.API_FLASK_DEBUG, host=settings.
        API_FLASK_SERVER_HOST, port=settings.API_FLASK_SERVER_PORT)


if __name__ == '__main__':
    main()


import os
import inspect
import logging
from logging.handlers import TimedRotatingFileHandler

from flask import Flask
from flask_cors import CORS

from src.api.endpoints.ns_move import api as ns5
from src.api.endpoints.ns_browse import api as ns6
from src.api.endpoints.ns_trash import api as ns7
from src.api.endpoints.ns_preview import api as ns8
from src.api.endpoints.ns_init import api as ns9

from src.api.restplus import api
import settings

################################################################################
# SETUP LOGGING
################################################################################

pathToThisPyFile = inspect.getfile(inspect.currentframe())
path, filename = os.path.split(pathToThisPyFile)
filename = os.path.splitext(filename)[0] + '.log'
log_folder_path = os.path.join(path, 'logs')
if not os.path.exists(log_folder_path):
    os.mkdir(log_folder_path)
log_path = os.path.join(log_folder_path, filename)

format_string = '%(asctime)s - [%(levelname)s] %(name)s [%(module)s, line %(lineno)d]: %(message)s'

# set up logging to file
logging.basicConfig(level=logging.DEBUG,
                    format=format_string,
                    datefmt='%Y-%m-%d %H:%M')

# set a format which is simpler for console use
formatter = logging.Formatter(format_string)

# define handler
file_log = TimedRotatingFileHandler(log_path, when='W6')
file_log.setLevel(logging.DEBUG)
file_log.setFormatter(formatter)

# add the handlers to the root logger
logging.getLogger().addHandler(file_log)

log = logging.getLogger(__name__)

################################################################################
# SETUP FLASK
################################################################################

app = Flask(__name__)


def configure_app(flask_app):
    # flask_app.config['SERVER_NAME'] = settings.FLASK_SERVER_NAME
    flask_app.config['SWAGGER_UI_DOC_EXPANSION'] = settings.RESTPLUS_SWAGGER_UI_DOC_EXPANSION
    flask_app.config['RESTPLUS_VALIDATE'] = settings.RESTPLUS_VALIDATE
    flask_app.config['RESTPLUS_MASK_SWAGGER'] = settings.RESTPLUS_MASK_SWAGGER
    flask_app.config['ERROR_404_HELP'] = settings.RESTPLUS_ERROR_404_HELP


def initialize_app(flask_app):
    CORS(app)
    configure_app(flask_app)

    api.add_namespace(ns5)
    api.add_namespace(ns6)
    api.add_namespace(ns7)
    api.add_namespace(ns8)
    api.add_namespace(ns9)


def main():

    log.info("================================================================")
    log.info("INITIALISING APP")
    log.info("================================================================")
    initialize_app(app)
    api.init_app(app)
    app.run(debug=settings.API_FLASK_DEBUG, host=settings.API_FLASK_SERVER_HOST, port=settings.API_FLASK_SERVER_PORT)


if __name__ == "__main__":
    main()

    # TODO: check all important settings exist and have valid values


