Skip to content

Commit

Permalink
Simplification chargement route api
Browse files Browse the repository at this point in the history
  • Loading branch information
amandine-sahl committed Apr 27, 2023
1 parent 24d51a9 commit 192f31c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 29 deletions.
10 changes: 10 additions & 0 deletions apptax/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
taxhub_routes = [
("apptax.utils.routesconfig:adresses", "/api/config"),
("apptax.taxonomie.routesbibnoms:adresses", "/api/bibnoms"),
("apptax.taxonomie.routestaxref:adresses", "/api/taxref"),
("apptax.taxonomie.routesbibattributs:adresses", "/api/bibattributs"),
("apptax.taxonomie.routesbiblistes:adresses", "/api/biblistes"),
("apptax.taxonomie.routestmedias:adresses", "/api/tmedias"),
("apptax.taxonomie.routesbdcstatuts:adresses", "/api/bdc_statuts"),
("apptax.admin.admin:adresses", None),
]
36 changes: 7 additions & 29 deletions apptax/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import logging
from pkg_resources import iter_entry_points
from pathlib import Path
from importlib import import_module
from flask import Flask, current_app, send_from_directory, request, g
from flask_cors import CORS
from flask_migrate import Migrate
Expand Down Expand Up @@ -108,35 +109,12 @@ def favicon():
taxhub_admin.init_app(app)
taxhub_admin_addview(app, taxhub_admin)

from apptax.utils.routesconfig import adresses
# API
from apptax import taxhub_routes

app.register_blueprint(adresses, url_prefix="/api/config")

from apptax.taxonomie.routesbibnoms import adresses

app.register_blueprint(adresses, url_prefix="/api/bibnoms")

from apptax.taxonomie.routestaxref import adresses

app.register_blueprint(adresses, url_prefix="/api/taxref")

from apptax.taxonomie.routesbibattributs import adresses

app.register_blueprint(adresses, url_prefix="/api/bibattributs")

from apptax.taxonomie.routesbiblistes import adresses

app.register_blueprint(adresses, url_prefix="/api/biblistes")

from apptax.taxonomie.routestmedias import adresses

app.register_blueprint(adresses, url_prefix="/api/tmedias")

from apptax.taxonomie.routesbdcstatuts import adresses

app.register_blueprint(adresses, url_prefix="/api/bdc_statuts")
from apptax.admin.admin import adresses

app.register_blueprint(adresses)
for blueprint_path, url_prefix in taxhub_routes:
module_name, blueprint_name = blueprint_path.split(":")
blueprint = getattr(import_module(module_name), blueprint_name)
app.register_blueprint(blueprint, url_prefix=url_prefix)

return app

0 comments on commit 192f31c

Please sign in to comment.