53 lines
1.4 KiB
Python
53 lines
1.4 KiB
Python
import logging
|
|
import logging.config
|
|
|
|
logging.basicConfig(level=logging.INFO)
|
|
|
|
from flask import url_for, render_template
|
|
from flask_sqlalchemy import SQLAlchemy
|
|
from flask_security import Security, SQLAlchemyUserDatastore
|
|
from flask_social import Social
|
|
from flask_social.datastore import SQLAlchemyConnectionDatastore
|
|
from flask_mail import Mail
|
|
from flask_migrate import Migrate
|
|
from flask_admin import Admin
|
|
from flask_wtf.csrf import CsrfProtect
|
|
from flask.ext.markdown import Markdown
|
|
from flask_pagedown import PageDown
|
|
|
|
db = SQLAlchemy()
|
|
security = Security()
|
|
social = Social()
|
|
mail = Mail()
|
|
migrate = Migrate()
|
|
admin = Admin(template_mode='bootstrap3')
|
|
|
|
|
|
def init_app(app):
|
|
db.init_app(app)
|
|
mail.init_app(app)
|
|
admin.init_app(app)
|
|
migrate.init_app(app, db)
|
|
|
|
@app.context_processor
|
|
def utility_processor():
|
|
return {
|
|
'static': lambda fn: url_for('static', filename=fn)
|
|
}
|
|
|
|
@app.errorhandler(404)
|
|
def page_not_found(e):
|
|
return render_template('404.html'), 404
|
|
|
|
if app.config.get('LOGGING'):
|
|
logging.config.dictConfig(app.config['LOGGING'])
|
|
|
|
from auth.models import User, Role, Connection
|
|
security.init_app(app, SQLAlchemyUserDatastore(db, User, Role))
|
|
social._state = social.init_app(
|
|
app, SQLAlchemyConnectionDatastore(db, Connection))
|
|
|
|
CsrfProtect(app)
|
|
Markdown(app)
|
|
PageDown(app)
|