This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
cne.py
91 lines (65 loc) · 2.42 KB
/
cne.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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
from flask_assets import Environment, Bundle
from flask_caching import Cache
from environs import Env
from flask import Flask
# -----------------------------------------------------------
# App bootstrap
env = Env()
env.read_env()
app = Flask(__name__)
app.config.update(
# Default config values that may be overwritten by environment values
SECRET_KEY=env.str('SECRET_KEY'),
CACHE_TYPE=env.str('CACHE_TYPE', default='FileSystemCache'),
CACHE_DIR=env.str('CACHE_DIR', default='instance/cache'),
ASSETS_CACHE=env.str('ASSETS_CACHE', default='instance/webassets-cache'),
DEBUG_TB_INTERCEPT_REDIRECTS=env.bool('DEBUG_TB_INTERCEPT_REDIRECTS', False),
MINIFY_HTML=env.bool('MINIFY_HTML', default=False),
COMPRESS_REGISTER=env.bool('COMPRESS_REGISTER', default=False),
COMPRESS_MIN_SIZE=env.int('COMPRESS_MIN_SIZE', 512),
# Config values that cannot be overwritten
ITEMS_IMAGES_DIR='static/images/items/{game_version}',
ITEMS_FILE='data/{game_version}/items.json',
RECIPES_FILE='data/{game_version}/recipes.json',
ESCAPISTS_WIKI_DOMAIN='theescapists.gamepedia.com',
CACHE_THRESHOLD=10000,
)
# -----------------------------------------------------------
# Debugging-related behaviours
if app.config['DEBUG']:
import logging
logging.basicConfig(level=logging.DEBUG)
# -----------------------------------------------------------
# Flask extensions initialization and configuration
# Flask-DebugToolbar
if app.config['DEBUG']:
try:
from flask_debugtoolbar import DebugToolbarExtension
debug_toolbar = DebugToolbarExtension(app)
except ImportError:
pass
# Flask-Compress
try:
from flask_compress import Compress
compress = Compress(app)
except ImportError:
pass
# Flask-HTMLmin
try:
from flask_htmlmin import HTMLMIN
htmlmin = HTMLMIN(app)
except ImportError:
pass
# Flask-Assets
assets = Environment(app)
assets.register('js_home', Bundle('js/common.js', 'js/home.js', filters='jsmin', output='js/home.min.js'))
assets.register('js_recipes_editor', Bundle('js/common.js', 'js/recipes_editor.js', filters='jsmin', output='js/recipes_editor.min.js'))
assets.register('css_app', Bundle('css/app.css', filters='cssutils', output='css/app.min.css'))
# Flask-Caching
cache = Cache(app)
from helpers import *
# -----------------------------------------------------------
# After-bootstrap imports
import routes
import commands
import hooks