forked from trev-dev/flask-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfactory.py
38 lines (30 loc) · 1 KB
/
factory.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from config import DevConfig, ProdConfig
from flask import Flask
from flask_assets import Environment, Bundle
from routes.get import get
# from routes.post import post
CONFIGS = {'dev': DevConfig, 'prod': ProdConfig}
def create_app(env):
config = CONFIGS[env]
# Instantiate Flask
app = Flask(
__name__,
template_folder=config.TEMPLATE_FOLDER,
static_path=config.STATIC_PATH,
static_folder=config.STATIC_FOLDER
)
app.config.from_object(config)
assets = Environment(app)
# JS/CSS bundlers for minification
js = Bundle('js/site.js', filters='jsmin', output='js/bundle.min.js')
css = Bundle(
'css/styles.css',
filters='cssmin',
output='css/bundle.min.css'
)
assets.register('js_modules', js)
assets.register('css_modules', css)
# Apply GET method routes
app.register_blueprint(get)
# app.register_blueprint(post)
return app