Refactor blueprints and namespaces

This commit is contained in:
Chris Diesch 2025-04-06 16:05:40 -06:00
parent 495cf994cb
commit 8c5a6d9743
5 changed files with 19 additions and 16 deletions

12
api.py Normal file
View File

@ -0,0 +1,12 @@
from flask_restx import api
from flask import Blueprint
from .MRE.api import namespace as mre_namespace
blueprint = Blueprint('api', __name__)
api = Api(
blueprint,
doc='/doc/',
title='Quarter API documentatoin'
)
api.add_namespace(mre_namespace, '/mre')

View File

@ -1,7 +1,4 @@
from flask import Blueprint
from .api import api_blueprint
from flask_restx import Namespace
mre_blueprint = Blueprint('mre_blueprint',
__name__,
url_prefix='mre')
mre_blueprint.register_blueprint(api_blueprint)
namespace = Namespace('mre',
description='Endpoints for MRE calculations')

View File

@ -1,5 +0,0 @@
from flask import Blueprint
api_blueprint = Blueprint('api_blueprint',
__name__,
url_prefix='api')

View File

@ -2,9 +2,7 @@ from flask import current_app
from flask_restx import Api, fields, apidoc, Model, Namespace, Resource
from flask_restx.reqparse import RequestParser
from MRE_module import compute_mre
namespace = Namespace('mre',
description='Endpoints for MRE calculations')
from . import namespace
MRE_request_parser = RequestParser()
MRE_request_parser.add_argument('consumer_fico',

View File

@ -1,8 +1,8 @@
from flask import Flask
import os
from app.MRE import mre_blueprint
from logging import Logger, Formatter, getLogger, DEBUG, INFO,
FileHandler
from .api import blueprint as api_blueprint
from logging import Logger, Formatter, getLogger, DEBUG, INFO, FileHandler
def load_config_from_environ(app: Flask) -> Flask:
@ -31,5 +31,6 @@ def create_app(app_name: str='MRE') -> Flask:
app = init_logger(app)
app.register_blueprint(mre_blueprint)
app.register_blueprint(api_blueprint)
return app