|
|
@ -1,8 +1,8 @@ |
|
|
|
from config import Config |
|
|
|
import os |
|
|
|
import logging |
|
|
|
import logging |
|
|
|
|
|
|
|
|
|
|
|
from logging.handlers import SMTPHandler |
|
|
|
from logging.handlers import SMTPHandler |
|
|
|
from logging.handlers import RotatingFileHandler |
|
|
|
from logging.handlers import RotatingFileHandler |
|
|
|
import os |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from flask import Flask |
|
|
|
from flask import Flask |
|
|
|
from flask_bootstrap import Bootstrap |
|
|
|
from flask_bootstrap import Bootstrap |
|
|
@ -11,17 +11,26 @@ from flask_migrate import Migrate |
|
|
|
from flask_login import LoginManager |
|
|
|
from flask_login import LoginManager |
|
|
|
from flask_moment import Moment |
|
|
|
from flask_moment import Moment |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from config import Config |
|
|
|
|
|
|
|
|
|
|
|
app = Flask(__name__) |
|
|
|
db = SQLAlchemy() |
|
|
|
app.config.from_object(Config) |
|
|
|
bootstrap = Bootstrap() |
|
|
|
bootstrap = Bootstrap(app) |
|
|
|
migrate = Migrate() |
|
|
|
db = SQLAlchemy(app) |
|
|
|
login = LoginManager() |
|
|
|
migrate = Migrate(app, db) |
|
|
|
|
|
|
|
login = LoginManager(app) |
|
|
|
|
|
|
|
login.login_view = 'login' |
|
|
|
login.login_view = 'login' |
|
|
|
moment = Moment(app) |
|
|
|
login.login_message = 'Please log in to access this page.' |
|
|
|
|
|
|
|
moment = Moment() |
|
|
|
|
|
|
|
|
|
|
|
from app import routes, models, errors |
|
|
|
def create_app(config_class=Config): |
|
|
|
|
|
|
|
# pylint: disable=no-member |
|
|
|
|
|
|
|
app = Flask(__name__) |
|
|
|
|
|
|
|
app.config.from_object(config_class) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
db.init_app(app) |
|
|
|
|
|
|
|
bootstrap.init_app(app) |
|
|
|
|
|
|
|
migrate.init_app(app, db) |
|
|
|
|
|
|
|
login.init_app(app) |
|
|
|
|
|
|
|
moment.init_app(app) |
|
|
|
|
|
|
|
|
|
|
|
if not app.debug and not app.testing: |
|
|
|
if not app.debug and not app.testing: |
|
|
|
if app.config['MAIL_SERVER']: |
|
|
|
if app.config['MAIL_SERVER']: |
|
|
@ -57,3 +66,7 @@ if not app.debug and not app.testing: |
|
|
|
|
|
|
|
|
|
|
|
app.logger.setLevel(logging.INFO) |
|
|
|
app.logger.setLevel(logging.INFO) |
|
|
|
app.logger.info('Microblog startup') |
|
|
|
app.logger.info('Microblog startup') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return app |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from app import routes, models, errors |
|
|
|