Completed
Push — master ( 7eb213...41374a )
by -
01:29
created

f_scoresplit()   A

Complexity

Conditions 1

Size

Total Lines 6

Duplication

Lines 0
Ratio 0 %
Metric Value
cc 1
dl 0
loc 6
rs 9.4285
1
import base64
2
import os
3
import logging
4
5
from flask import Flask
6
from flask.ext.bootstrap import Bootstrap
7
8
from spike.views import default, rules, rulesets, sandbox
9
from spike.model import db
10
11
version = "0.5 "
12
13
14
def create_app(config_filename=''):
15
    logging.info("Spike app.init()")
16
17
    app = Flask(__name__)
18
19
    if config_filename:
20
        app.config.from_pyfile(config_filename)
21
22
    if not app.config["SECRET_KEY"]:
23
        app.config["SECRET_KEY"] = base64.b64encode(os.urandom(128))
24
25
    app.config["SQLALCHEMY_BINDS"] = {'rules': 'sqlite:///rules.db'}
26
27
    db.init_app(app)
28
    db.app = app
29
30
    Bootstrap(app)  # add bootstrap templates and css
31
32
    # add blueprints
33
    app.register_blueprint(default.default)
34
    app.register_blueprint(rules.rules, url_prefix='/rules')
35
    app.register_blueprint(rulesets.rulesets, url_prefix='/rulesets')
36
    app.register_blueprint(sandbox.sandbox, url_prefix='/sandbox')
37
38
    # register filters
39
    app.jinja_env.globals['version'] = version
40
41
    return app
42