-
Notifications
You must be signed in to change notification settings - Fork 12
/
__init__.py
45 lines (36 loc) · 1.36 KB
/
__init__.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
import logging
from flask import Flask
from flask.ext.bootstrap import Bootstrap
from flask.ext.security import Security, user_registered
from flask_wtf.csrf import CsrfProtect
from flask_mail import Mail
from flask_migrate import Migrate
from .models import db, user_datastore
from .error_mail import email_exception
from .views import ratings as ratings_blueprint, user_registered_sighandler
from .api_1_0 import api as api_1_0_blueprint
from .tournament import tournament as tournament_blueprint
from .verify import verify as verify_blueprint
from flask.ext.rq import RQ
mail = Mail()
def get_app(config):
app = Flask(__name__)
app.config.from_object(config)
mail.init_app(app)
RQ(app)
csrf = CsrfProtect(app)
csrf.exempt(api_1_0_blueprint)
stream_handler = logging.StreamHandler()
app.logger.setLevel(logging.DEBUG)
app.logger.addHandler(stream_handler)
db.init_app(app)
Migrate(app, db)
bootstrap = Bootstrap(app)
security = Security(app, user_datastore)
user_registered.connect(user_registered_sighandler)
app.register_blueprint(ratings_blueprint)
app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1')
app.register_blueprint(verify_blueprint, url_prefix='/v')
app.register_blueprint(tournament_blueprint, url_prefix='/tournament')
app.register_error_handler(500, email_exception)
return app