1
0
Fork 0
web2019/server/app/__init__.py

32 lines
670 B
Python
Raw Normal View History

from flask import Flask
from flask_cors import CORS
from flask_mail import Mail
from werkzeug.middleware.proxy_fix import ProxyFix
import config
mail = Mail()
def create_app(cfg=config):
app = Flask(__name__)
app.config.from_object(cfg)
app.wsgi_app = ProxyFix(app.wsgi_app)
mail.init_app(app)
from app.api import bp as bp_api
app.register_blueprint(bp_api)
CORS(
app,
resources={r'/api/*': {
'methods': ['POST', 'OPTIONS'],
'allow_origins': app.config['CORS_ALLOWED_ORIGINS'].split(','),
'allow_headers': app.config['CORS_ALLOWED_HEADERS'].split(','),
}})
return app