forked from limbov8/fire
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
44 lines (32 loc) · 1.3 KB
/
app.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
from flask import Flask, Blueprint, render_template
from flask_wtf import CSRFProtect
from flask_assets import Environment
from config import app_config, routes
def create_app(config_name='development'):
app_name = app_config[config_name].APP_NAME or __name__
app = Flask(app_name)
app.config.from_object(app_config[config_name])
csrf = CSRFProtect()
csrf.init_app(app)
assets = Environment(app)
app.static_folder = 'public'
with app.app_context():
from .route import Route
import app as user_app
blueprint = Blueprint('public', 'public', static_url_path='/public', static_folder='public')
app.register_blueprint(blueprint)
blueprint = Blueprint('app', 'app', template_folder='templates')
app.register_blueprint(blueprint)
rt = Route(routes)
rt.init_app(app)
user_app.init_app(app, csrf, assets)
@app.errorhandler(403)
def forbidden(error):
return render_template('error/403.html', title='Forbidden'), 403
@app.errorhandler(404)
def page_not_found(error):
return render_template('error/404.html', title='Page Not Found'), 404
@app.errorhandler(500)
def internal_server_error(error):
return render_template('error/500.html', title='Server Error'), 500
return app