1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-11-01 03:25:55 +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 # Register all template filters and template globals
app.register_blueprint(template_utils.bp)
# Register the API routes
# #################################### BLUEPRINTS #################################### app.register_blueprint(api_blueprint, url_prefix='/api')
# Register the site's routes
def register_blueprints(flask_app): views.register(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)

View file

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