Refactor blueprints and namespaces
This commit is contained in:
parent
495cf994cb
commit
8c5a6d9743
12
api.py
Normal file
12
api.py
Normal 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')
|
||||
|
||||
@ -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')
|
||||
|
||||
@ -1,5 +0,0 @@
|
||||
from flask import Blueprint
|
||||
|
||||
api_blueprint = Blueprint('api_blueprint',
|
||||
__name__,
|
||||
url_prefix='api')
|
||||
@ -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',
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user