Exemple #1
0
def test_blueprints():
    app = make_app()

    test_dir = os.path.dirname(__file__)
    bluep = Blueprint(
        'bluep',
        'blueprint',
        static_folder=os.path.join(test_dir, 'bluep_static'),
    )

    fanstatic = Fanstatic(bluep)
    fanstatic.resource('bluep.js', name='bluep_js')

    @bluep.route('/')
    def bluep_index():
        return render_template('bluep.html')

    app.register_blueprint(bluep, url_prefix='/bluep')

    with app.test_client() as client:
        rv = client.get('/bluep/')
        expect(rv.data).contains('/fanstatic/bluep/bluep.js')

        rv = client.get('/fanstatic/bluep/bluep.js')
        expect(rv.status_code) == 200
def test_app_resources():
  app = make_app()
  fanstatic = Fanstatic(app)
  fanstatic.resource('app.js', name='app_js')

  with app.test_client() as client:
    rv = client.get('/template/needs_app_js')
    expect(rv.data).contains('/fanstatic/app/app.js')

    rv = client.get('/fanstatic/app/app.js')
    expect(rv.status_code) == 200
Exemple #3
0
def test_app_resources():
    app = make_app()
    fanstatic = Fanstatic(app)
    fanstatic.resource('app.js', name='app_js')

    with app.test_client() as client:
        rv = client.get('/template/needs_app_js')
        expect(rv.data).contains('/fanstatic/app/app.js')

        rv = client.get('/fanstatic/app/app.js')
        expect(rv.status_code) == 200
def test_blueprints():
  app = make_app()

  test_dir = os.path.dirname(__file__)
  bluep = Blueprint('bluep', 'blueprint',
    static_folder=os.path.join(test_dir, 'bluep_static'),
  )

  fanstatic = Fanstatic(bluep)
  fanstatic.resource('bluep.js', name='bluep_js')

  @bluep.route('/')
  def bluep_index():
    return render_template('bluep.html')

  app.register_blueprint(bluep, url_prefix='/bluep')

  with app.test_client() as client:
    rv = client.get('/bluep/')
    expect(rv.data).contains('/fanstatic/bluep/bluep.js')

    rv = client.get('/fanstatic/bluep/bluep.js')
    expect(rv.status_code) == 200
#!/usr/bin/env python
# -*- coding: utf-8 -*-
 
# Copyright 2013 Alexandre Bulté <alexandre[at]bulte[dot]net>
# 
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.

from flask import Flask, render_template
from flask_fanstatic import Fanstatic

# configuration
DEBUG = True
FANSTATIC_OPTIONS = {'bottom': True, 'minified': True}

app = Flask(__name__)
app.config.from_object(__name__)
fanstatic = Fanstatic(app)

# define your own ressources this way
fanstatic.resource('js/app.js', name='app_js', bottom=True)

@app.route('/')
def index():
    return render_template('index.html')
Exemple #6
0
from flask_login import LoginManager


##- Init and configure -##

def get_config():
    if os.environ.get('FLASK_ENV', '') == 'PROD':
        return 'webapp.settings.ProductionConfig'
    else:
        return 'webapp.settings.DevelopmentConfig'

app = Flask(__name__)
app.config.from_object(get_config())
db = MongoEngine(app)

##- Login -##

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = "login"

##- Resources -##

fanstatic = Fanstatic(app)
fanstatic.resource('js/app.js', name='app_js', bottom=True)

##- Imports -##

import webapp.views
import webapp.admin
Exemple #7
0
def app_client(**options):
    app = make_app(**options)
    Fanstatic(app)
    return app.test_client()
Exemple #8
0
# -*- coding: utf-8 -*-
from flask import Flask
from flask_beaker import BeakerSession
from flask_cache import Cache
from flask_fanstatic import Fanstatic
from flask_pymongo import PyMongo

__author__ = 'viruzzz-kun'

app = Flask(__name__)
mongo = PyMongo()
fanstatic = Fanstatic()