1
0
Fork 0
mirror of https://gitlab.com/SIGBUS/nyaa.git synced 2024-12-22 15:10:01 +00:00

Optimize routes (define url_prefix in Blueprints)

* /admin/*
* /api/*
This commit is contained in:
Kfir Hadas 2017-08-15 17:12:54 +03:00
parent 0bcd782695
commit a758f5f078
3 changed files with 5 additions and 5 deletions

View file

@ -78,7 +78,7 @@ def create_app(config):
# Blueprints # Blueprints
app.register_blueprint(template_utils_bp) app.register_blueprint(template_utils_bp)
app.register_blueprint(api_blueprint, url_prefix='/api') app.register_blueprint(api_blueprint)
register_views(app) register_views(app)
return app return app

View file

@ -10,7 +10,7 @@ from nyaa import backend, bencode, forms, models, utils
from nyaa.extensions import db from nyaa.extensions import db
from nyaa.views.torrents import _create_upload_category_choices from nyaa.views.torrents import _create_upload_category_choices
api_blueprint = flask.Blueprint('api', __name__) api_blueprint = flask.Blueprint('api', __name__, url_prefix='/api')
# #################################### API HELPERS #################################### # #################################### API HELPERS ####################################

View file

@ -3,10 +3,10 @@ import flask
from nyaa import forms, models from nyaa import forms, models
from nyaa.extensions import db from nyaa.extensions import db
bp = flask.Blueprint('admin', __name__) bp = flask.Blueprint('admin', __name__, url_prefix='/admin')
@bp.route('/admin/log', endpoint='log', methods=['GET']) @bp.route('/log', endpoint='log', methods=['GET'])
def view_adminlog(): def view_adminlog():
if not flask.g.user or not flask.g.user.is_moderator: if not flask.g.user or not flask.g.user.is_moderator:
flask.abort(403) flask.abort(403)
@ -20,7 +20,7 @@ def view_adminlog():
adminlog=logs) adminlog=logs)
@bp.route('/admin/reports', endpoint='reports', methods=['GET', 'POST']) @bp.route('/reports', endpoint='reports', methods=['GET', 'POST'])
def view_reports(): def view_reports():
if not flask.g.user or not flask.g.user.is_moderator: if not flask.g.user or not flask.g.user.is_moderator:
flask.abort(403) flask.abort(403)