Rename blueprints and api.

This commit is contained in:
Alexis Lahouze 2016-01-13 00:02:38 +01:00
parent fe525dde46
commit 832da874c9
7 changed files with 20 additions and 20 deletions

View File

@ -30,8 +30,8 @@ app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
db = SQLAlchemy(app)
# Must be after db declaration because the blueprints may need it.
from .api import api
from .frontend import frontend, frontend_js, frontend_css
from .api import blueprint as api
from .frontend import blueprint as frontend, frontend_js, frontend_css
app.register_blueprint(frontend, url_prefix='/app')
app.register_blueprint(api, url_prefix='/api')

View File

@ -17,8 +17,8 @@
from flask import Blueprint
from flask.ext.restful import Api
api = Blueprint('api', __name__)
api_api = Api(api)
blueprint = Blueprint('api', __name__)
api = Api(blueprint)
# Load all views.
from .views import *

View File

@ -22,7 +22,7 @@ from sqlalchemy.orm.exc import NoResultFound
from accountant import db
from .. import api_api
from .. import api
from ..models.accounts import Account
from ..models.operations import Operation
@ -143,8 +143,8 @@ class AccountResource(Resource):
return None, 204
api_api.add_resource(AccountListResource, '/accounts')
api_api.add_resource(AccountResource, '/accounts/<int:id>')
api.add_resource(AccountListResource, '/accounts')
api.add_resource(AccountResource, '/accounts/<int:id>')
range_parser = reqparse.RequestParser()
@ -187,5 +187,5 @@ class SoldsResource(Resource):
return Operation.get_ohlc_per_day_for_range(**data).all(), 200
api_api.add_resource(CategoriesResource, "/categories")
api_api.add_resource(SoldsResource, "/solds")
api.add_resource(CategoriesResource, "/categories")
api.add_resource(SoldsResource, "/solds")

View File

@ -20,7 +20,7 @@ from flask.ext.restful import Resource, fields, reqparse, marshal_with_field
from accountant import db
from .. import api_api
from .. import api
from ..models.operations import Operation
@ -136,5 +136,5 @@ class OperationResource(Resource):
return None, 204
api_api.add_resource(OperationListResource, "/operations")
api_api.add_resource(OperationResource, "/operations/<int:id>")
api.add_resource(OperationListResource, "/operations")
api.add_resource(OperationResource, "/operations/<int:id>")

View File

@ -26,7 +26,7 @@ from accountant import db
from ..models.scheduled_operations import ScheduledOperation
from ..models.operations import Operation
from .. import api_api
from .. import api
from ..fields import Object
@ -159,6 +159,6 @@ class ScheduledOperationResource(Resource):
return None, 204
api_api.add_resource(ScheduledOperationListResource, "/scheduled_operations")
api_api.add_resource(ScheduledOperationResource,
api.add_resource(ScheduledOperationListResource, "/scheduled_operations")
api.add_resource(ScheduledOperationResource,
"/scheduled_operations/<int:id>")

View File

@ -28,7 +28,7 @@ from werkzeug.exceptions import BadRequest
from accountant import app
from .. import api_api
from .. import api
from ..fields import Object
@ -126,4 +126,4 @@ class LoginResource(Resource):
return g.user
api_api.add_resource(LoginResource, "/users/login")
api.add_resource(LoginResource, "/users/login")

View File

@ -1,7 +1,7 @@
from flask import Blueprint, render_template
from flask.ext.assets import Environment, Bundle
frontend = Blueprint(
blueprint = Blueprint(
'frontend',
__name__,
template_folder='templates',
@ -15,7 +15,7 @@ frontend_js = Bundle('frontend/js/app.js', 'frontend/js/accounts.js',
frontend_css = Bundle('frontend/css/main.css')
@frontend.route('/', defaults={'path': 'accounts'})
@frontend.route('/<path:path>')
@blueprint.route('/', defaults={'path': 'accounts'})
@blueprint.route('/<path:path>')
def index(path):
return render_template('layout.html')