示例#1
0
def create_app(config=None, environment=None):
    app = Flask(__name__)
    app.config['ENVIRONMENT'] = environment
    app.config.load()
    app.config.update(config or {})
    if not (app.config['ENVIRONMENT'] == 'development' or
            app.config['TESTING']):
        app.config['SERVER_NAME'] = app.config['SITE_URL']

    security.init_app(app, user_datastore)
    db.init_app(app)
    admin.init_app(app)
    app.register_blueprint(index_bp)

    register_processors(app)

    return app
示例#2
0
def create_app(config=None, environment=None):
    app = Flask(__name__)
    app.config['ENVIRONMENT'] = environment
    app.config.load()
    app.config.update(config or {})
    if not (app.config['ENVIRONMENT'] == 'development'
            or app.config['TESTING']):
        app.config['SERVER_NAME'] = app.config['SITE_URL']

    security.init_app(app, user_datastore)
    db.init_app(app)
    admin.init_app(app)
    app.register_blueprint(index_bp)

    register_processors(app)

    return app
示例#3
0
# -*- coding:utf-8 -*-
# filename:__init__.py
# 16/2/8 下午1:19
from flask_bootstrap import Bootstrap
from flask_login import LoginManager
from flask_mail import Mail
from flask_sqlalchemy import SQLAlchemy
from app.views.admin import admin, login_manager
from app.views.bpViews import test

__author__ = 'bingone'
from flask import Flask

app = Flask(__name__)  # 创建Flask类的实例
app.config.from_object("config")  # 从config.py读入配置
bootstrap = Bootstrap(app)
# blue print http://www.cnblogs.com/ymy124/p/4417525.html
app.register_blueprint(test)
admin.init_app(app)
# 这个import语句放在这里, 防止views, models import发生循环import
# from app.views import showDB, addDB, delDB,modDB,common, errors
from app.views import schoolViews,alumniViews,crawlerRecordViews,common, errors,userViews,chartViews

def strToLong(arg):
    if arg==None or not arg.strip():
        return 23333L
    return long(arg)+1000000L
app.jinja_env.globals.update(strToLong=strToLong)
示例#4
0
import os

# app初始化,
# instance_relative_config 设置config文件可从Instance文件中查找
app = Flask(__name__, instance_relative_config=True)

# 配置文件导入
app.config.from_object(config['development'])

# 数据库管理
db = SQLAlchemy()
# 数据库配置初始化
db.init_app(app)

# 后面需要调用db的,导入时需要放在db初始化完成之后
from app.views.admin import admin
admin.init_app(app)
'''
统一拦截处理和统一错误处理
'''
#  from app.interceptor.ApiInterceptor import  *
'''
蓝图功能,对所有的url进行蓝图功能配置
'''

from app.views.index import index
from app.views.api import route_api

app.register_blueprint(index, url_prefix='/')
app.register_blueprint(route_api, url_prefix='/api')