Rename blueprints and api.
This commit is contained in:
parent
fe525dde46
commit
832da874c9
@ -30,8 +30,8 @@ app.config['SQLALCHEMY_COMMIT_ON_TEARDOWN'] = True
|
|||||||
db = SQLAlchemy(app)
|
db = SQLAlchemy(app)
|
||||||
|
|
||||||
# Must be after db declaration because the blueprints may need it.
|
# Must be after db declaration because the blueprints may need it.
|
||||||
from .api import api
|
from .api import blueprint as api
|
||||||
from .frontend import frontend, frontend_js, frontend_css
|
from .frontend import blueprint as frontend, frontend_js, frontend_css
|
||||||
|
|
||||||
app.register_blueprint(frontend, url_prefix='/app')
|
app.register_blueprint(frontend, url_prefix='/app')
|
||||||
app.register_blueprint(api, url_prefix='/api')
|
app.register_blueprint(api, url_prefix='/api')
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
from flask import Blueprint
|
from flask import Blueprint
|
||||||
from flask.ext.restful import Api
|
from flask.ext.restful import Api
|
||||||
|
|
||||||
api = Blueprint('api', __name__)
|
blueprint = Blueprint('api', __name__)
|
||||||
api_api = Api(api)
|
api = Api(blueprint)
|
||||||
|
|
||||||
# Load all views.
|
# Load all views.
|
||||||
from .views import *
|
from .views import *
|
||||||
|
@ -22,7 +22,7 @@ from sqlalchemy.orm.exc import NoResultFound
|
|||||||
|
|
||||||
from accountant import db
|
from accountant import db
|
||||||
|
|
||||||
from .. import api_api
|
from .. import api
|
||||||
|
|
||||||
from ..models.accounts import Account
|
from ..models.accounts import Account
|
||||||
from ..models.operations import Operation
|
from ..models.operations import Operation
|
||||||
@ -143,8 +143,8 @@ class AccountResource(Resource):
|
|||||||
return None, 204
|
return None, 204
|
||||||
|
|
||||||
|
|
||||||
api_api.add_resource(AccountListResource, '/accounts')
|
api.add_resource(AccountListResource, '/accounts')
|
||||||
api_api.add_resource(AccountResource, '/accounts/<int:id>')
|
api.add_resource(AccountResource, '/accounts/<int:id>')
|
||||||
|
|
||||||
|
|
||||||
range_parser = reqparse.RequestParser()
|
range_parser = reqparse.RequestParser()
|
||||||
@ -187,5 +187,5 @@ class SoldsResource(Resource):
|
|||||||
return Operation.get_ohlc_per_day_for_range(**data).all(), 200
|
return Operation.get_ohlc_per_day_for_range(**data).all(), 200
|
||||||
|
|
||||||
|
|
||||||
api_api.add_resource(CategoriesResource, "/categories")
|
api.add_resource(CategoriesResource, "/categories")
|
||||||
api_api.add_resource(SoldsResource, "/solds")
|
api.add_resource(SoldsResource, "/solds")
|
||||||
|
@ -20,7 +20,7 @@ from flask.ext.restful import Resource, fields, reqparse, marshal_with_field
|
|||||||
|
|
||||||
from accountant import db
|
from accountant import db
|
||||||
|
|
||||||
from .. import api_api
|
from .. import api
|
||||||
|
|
||||||
from ..models.operations import Operation
|
from ..models.operations import Operation
|
||||||
|
|
||||||
@ -136,5 +136,5 @@ class OperationResource(Resource):
|
|||||||
return None, 204
|
return None, 204
|
||||||
|
|
||||||
|
|
||||||
api_api.add_resource(OperationListResource, "/operations")
|
api.add_resource(OperationListResource, "/operations")
|
||||||
api_api.add_resource(OperationResource, "/operations/<int:id>")
|
api.add_resource(OperationResource, "/operations/<int:id>")
|
||||||
|
@ -26,7 +26,7 @@ from accountant import db
|
|||||||
from ..models.scheduled_operations import ScheduledOperation
|
from ..models.scheduled_operations import ScheduledOperation
|
||||||
from ..models.operations import Operation
|
from ..models.operations import Operation
|
||||||
|
|
||||||
from .. import api_api
|
from .. import api
|
||||||
|
|
||||||
from ..fields import Object
|
from ..fields import Object
|
||||||
|
|
||||||
@ -159,6 +159,6 @@ class ScheduledOperationResource(Resource):
|
|||||||
return None, 204
|
return None, 204
|
||||||
|
|
||||||
|
|
||||||
api_api.add_resource(ScheduledOperationListResource, "/scheduled_operations")
|
api.add_resource(ScheduledOperationListResource, "/scheduled_operations")
|
||||||
api_api.add_resource(ScheduledOperationResource,
|
api.add_resource(ScheduledOperationResource,
|
||||||
"/scheduled_operations/<int:id>")
|
"/scheduled_operations/<int:id>")
|
||||||
|
@ -28,7 +28,7 @@ from werkzeug.exceptions import BadRequest
|
|||||||
|
|
||||||
from accountant import app
|
from accountant import app
|
||||||
|
|
||||||
from .. import api_api
|
from .. import api
|
||||||
|
|
||||||
from ..fields import Object
|
from ..fields import Object
|
||||||
|
|
||||||
@ -126,4 +126,4 @@ class LoginResource(Resource):
|
|||||||
return g.user
|
return g.user
|
||||||
|
|
||||||
|
|
||||||
api_api.add_resource(LoginResource, "/users/login")
|
api.add_resource(LoginResource, "/users/login")
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
from flask.ext.assets import Environment, Bundle
|
from flask.ext.assets import Environment, Bundle
|
||||||
|
|
||||||
frontend = Blueprint(
|
blueprint = Blueprint(
|
||||||
'frontend',
|
'frontend',
|
||||||
__name__,
|
__name__,
|
||||||
template_folder='templates',
|
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_css = Bundle('frontend/css/main.css')
|
||||||
|
|
||||||
|
|
||||||
@frontend.route('/', defaults={'path': 'accounts'})
|
@blueprint.route('/', defaults={'path': 'accounts'})
|
||||||
@frontend.route('/<path:path>')
|
@blueprint.route('/<path:path>')
|
||||||
def index(path):
|
def index(path):
|
||||||
return render_template('layout.html')
|
return render_template('layout.html')
|
||||||
|
Loading…
Reference in New Issue
Block a user