Using flask assets.
This commit is contained in:
parent
642b8c5b98
commit
fe53de1633
@ -18,9 +18,10 @@ from contextlib import contextmanager
|
|||||||
|
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
from flask import Flask
|
from flask import Flask, redirect, url_for
|
||||||
from flask.ext.sqlalchemy import SQLAlchemy
|
from flask.ext.sqlalchemy import SQLAlchemy
|
||||||
from flask.ext.bower import Bower
|
from flask.ext.bower import Bower
|
||||||
|
from flask.ext.assets import Environment, Bundle
|
||||||
|
|
||||||
from . import config
|
from . import config
|
||||||
|
|
||||||
@ -71,7 +72,7 @@ def session_aware(f):
|
|||||||
|
|
||||||
# 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 api
|
||||||
from .frontend import frontend
|
from .frontend import 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')
|
||||||
@ -80,5 +81,14 @@ app.register_blueprint(api, url_prefix='/api')
|
|||||||
app.config['BOWER_COMPONENTS_ROOT'] = "../bower_components"
|
app.config['BOWER_COMPONENTS_ROOT'] = "../bower_components"
|
||||||
app.config['BOWER_TRY_MINIFIED'] = not config.debug
|
app.config['BOWER_TRY_MINIFIED'] = not config.debug
|
||||||
|
|
||||||
|
|
||||||
bower = Bower(app)
|
bower = Bower(app)
|
||||||
|
|
||||||
|
assets = Environment(app)
|
||||||
|
|
||||||
|
assets.register('frontend_js', frontend_js)
|
||||||
|
assets.register('frontend_css', frontend_css)
|
||||||
|
|
||||||
|
|
||||||
|
@app.route('/')
|
||||||
|
def index():
|
||||||
|
return redirect(url_for('frontend.index'))
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
from flask import Blueprint, render_template
|
from flask import Blueprint, render_template
|
||||||
|
from flask.ext.assets import Environment, Bundle
|
||||||
|
|
||||||
frontend = Blueprint(
|
frontend = Blueprint(
|
||||||
'frontend',
|
'frontend',
|
||||||
@ -8,6 +9,12 @@ frontend = Blueprint(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
frontend_js = Bundle('frontend/js/app.js', 'frontend/js/accounts.js',
|
||||||
|
'frontend/js/entries.js', 'frontend/js/scheduler.js')
|
||||||
|
frontend_css = Bundle('frontend/css/main.css')
|
||||||
|
|
||||||
|
|
||||||
@frontend.route('/', defaults={'path': 'accounts'})
|
@frontend.route('/', defaults={'path': 'accounts'})
|
||||||
@frontend.route('/<path:path>')
|
@frontend.route('/<path:path>')
|
||||||
def index(path):
|
def index(path):
|
||||||
|
Loading…
Reference in New Issue
Block a user