1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-10-31 23:05:54 +00:00

Refactor routes.py

This commit is contained in:
Kfir Hadas 2017-07-26 18:11:00 +03:00
parent c539795fdc
commit 2424639bf9
2 changed files with 17 additions and 30 deletions

View file

@ -1,25 +1,9 @@
from nyaa import api_handler, app, template_utils, views
from nyaa import app, template_utils, views
from nyaa.api_handler import api_blueprint
DEBUG_API = False
# #################################### BLUEPRINTS ####################################
def register_blueprints(flask_app):
""" Register the blueprints using the flask_app object """
# Template filters and globals
flask_app.register_blueprint(template_utils.bp)
# API routes
flask_app.register_blueprint(api_handler.api_blueprint, url_prefix='/api')
# Site routes
flask_app.register_blueprint(views.account_bp)
flask_app.register_blueprint(views.admin_bp)
flask_app.register_blueprint(views.main_bp)
flask_app.register_blueprint(views.site_bp)
flask_app.register_blueprint(views.torrents_bp)
flask_app.register_blueprint(views.users_bp)
# When done, this can be moved to nyaa/__init__.py instead of importing this file
register_blueprints(app)
# Register all template filters and template globals
app.register_blueprint(template_utils.bp)
# Register the API routes
app.register_blueprint(api_blueprint, url_prefix='/api')
# Register the site's routes
views.register(app)

View file

@ -7,9 +7,12 @@ from nyaa.views import (
users,
)
account_bp = account.bp
admin_bp = admin.bp
main_bp = main.bp
site_bp = site.bp
torrents_bp = torrents.bp
users_bp = users.bp
def register(flask_app):
""" Register the blueprints using the flask_app object """
flask_app.register_blueprint(account.bp)
flask_app.register_blueprint(admin.bp)
flask_app.register_blueprint(main.bp)
flask_app.register_blueprint(site.bp)
flask_app.register_blueprint(torrents.bp)
flask_app.register_blueprint(users.bp)