示例#1
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    pagedown.init_app(app)
    assets.init_app(app)
    #markdown.init_app(app)

    if not app.debug and not app.testing and not app.config['SSL_DISABLE']:
        from flask.ext.sslify import SSLify
        sslify = SSLify(app)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    from .api_1_0 import api as api_1_0_blueprint
    app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1.0')

    return app
示例#2
0
def create_app():   # We could pass a config object here
    app = Flask(__name__)
    app.debug = os.environ.get('TIMERBOARD_PRODUCTION', True)
    app.config.from_envvar("TIMERBOARD_SETTINGS")
    with open(os.environ["TIMERBOARD_SETTINGS"]) as fh:
        app.myconfig = json.loads(fh.read())
    app.config["SQLALCHEMY_DATABASE_URI"] = app.myconfig["SQLALCHEMY_DATABASE_URI"]
    # Register template filters here
    # app.add_template_filter(some_method)

    #app.config.from_object(config)
    #app.config.from_pyfile(config_filename)

    app.secret_key = os.urandom(24)
    assets.init_app(app)
    login_manager.init_app(app)

    app.db = SQLAlchemy(app)
    with app.app_context():
        app.db.create_all()

    from users.views import mod as users_blueprint
    from assets import mod as assets_blueprint
    from login import mod as login_blueprint
    app.register_blueprint(users_blueprint)
    app.register_blueprint(assets_blueprint)
    app.register_blueprint(login_blueprint)

    @app.teardown_appcontext
    def shutdown_session(exception=None):
        app.db.session.remove()

    return app
示例#3
0
文件: app.py 项目: StasEvseev/buy_api
def create_app():
    application = Flask(__name__)
    application.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
    # application.config['BABEL_DEFAULT_LOCALE'] = 'ru-ru'
    application.config['SECRET_KEY'] = SECRET_KEY
    application.permanent_session_lifetime = timedelta(minutes=30)

    Triangle(application)
    assets.init_app(application)
    api.init_app(application)
    api.application = application
    db.init_app(application)
    admin.init_app(application)
    login_manager.init_app(application)
    application.db = db
    application.api = api

    babel = Babel(application)
    @babel.localeselector
    def get_locale():
        return request.accept_languages.best_match(["ru"])

    init_logging(application)

    return application
示例#4
0
def init_app(application):
    from resources import api
    from assets import assets
    from applications.security.auth import login_manager
    from security import security

    application.config['SQLALCHEMY_DATABASE_URI'] = DATABASE_URI
    application.config['SECURITY_TOKEN_AUTHENTICATION_HEADER'] = (
        "AUTHORIZATION")
    application.config['SECURITY_REMEMBER_SALT'] = "SALT123123123"
    application.config['SQLALCHEMY_ECHO'] = True
    application.config['SECRET_KEY'] = SECRET_KEY
    application.permanent_session_lifetime = timedelta(minutes=30)

    Triangle(application)
    assets.init_app(application)
    api.init_app(application)
    api.application = application
    db.init_app(application)
    login_manager.init_app(application)
    security.init_app(application)

    application.db = db
    application.api = api

    if IS_PROD:
        init_logging(application)

    return application
示例#5
0
def create_app(config_name):
    app = Flask(__name__)
    app.config.from_object(config[config_name])
    config[config_name].init_app(app)

    bootstrap.init_app(app)
    mail.init_app(app)
    moment.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    pagedown.init_app(app)
    assets.init_app(app)
    #markdown.init_app(app)

    if not app.debug and not app.testing and not app.config['SSL_DISABLE']:
        from flask.ext.sslify import SSLify
        sslify = SSLify(app)

    from .main import main as main_blueprint
    app.register_blueprint(main_blueprint)

    from .auth import auth as auth_blueprint
    app.register_blueprint(auth_blueprint, url_prefix='/auth')

    from .api_1_0 import api as api_1_0_blueprint
    app.register_blueprint(api_1_0_blueprint, url_prefix='/api/v1.0')

    return app
示例#6
0
def register_extensions(app):
    assets.init_app(app)
    bcrypt.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    login_manager.init_app(app)
    debug_toolbar.init_app(app)
    migrate.init_app(app, db)
    return None
示例#7
0
文件: app.py 项目: P2PTeam/enferno
def register_extensions(app):
    assets.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    admin.init_app(app)
    register_admin_views(admin)
    user_datastore = MongoEngineUserDatastore(db, User, Role)
    security = Security(app, user_datastore, confirm_register_form=ExtendedRegisterForm)
    mail.init_app(app)
    debug_toolbar.init_app(app)

    return None
示例#8
0
def register_extensions(app):
    assets.init_app(app)
    cache.init_app(app)
    db.init_app(app)
    admin.init_app(app)
    register_admin_views(admin)
    user_datastore = MongoEngineUserDatastore(db, User, Role)
    security = Security(app,
                        user_datastore,
                        confirm_register_form=ExtendedRegisterForm)
    mail.init_app(app)
    debug_toolbar.init_app(app)

    return None
示例#9
0
def create_app(config_name=None):
    """Entry point to flask-script"""
    app = Flask(__name__)
    app.clients = {}
    if config_name is None:
        config_name = os.environ['REGRUN_CONFIG']
    app.config.from_object(config[config_name]())

    # Initialize app extensions
    db.init_app(app)
    assets.init_app(app)
    socketio.init_app(app)

    from regrun import main as main_blueprint
    app.register_blueprint(main_blueprint)

    return app
示例#10
0
def create_app():
    app = Flask(__name__)

    file_handler = StreamHandler()
    app.logger.setLevel(logging.DEBUG)
    app.logger.addHandler(file_handler)

    app.config.from_object('dd.config')
    for k in app.config:
        v = os.environ.get(k, None)
        if v is not None:
            app.config[k] = v
    app.config['SQLALCHEMY_DATABASE_URI'] = app.config['DATABASE_URL']

    assets.init_app(app)
    manager.init_app(app)
    db.init_app(app)
    bcrypt.init_app(app)

    app.register_blueprint(admin, url_prefix='/admin')
    app.register_blueprint(public)
    return app
示例#11
0
from flask.ext.mail import Mail
from flask.ext.migrate import Migrate
from jinja2 import evalcontextfilter, Markup, escape
from db import *
from assets import assets
from admin import admin
from forms import *

app = Flask(__name__)
app.config.from_object('config')
app.config.from_object('keys')

mail = Mail(app)

db.init_app(app)
assets.init_app(app)
admin.init_app(app)

migrate = Migrate(app, db)



class MyUserDatastore(SQLAlchemyUserDatastore):
	def create_user(self, **kwargs):
		if not 'profile' in kwargs:
			kwargs['profile'] = Profile()
		return super(SQLAlchemyUserDatastore, self).create_user(**kwargs)

user_datastore = MyUserDatastore(db, User, Role)
security = Security(app, user_datastore)
示例#12
0
import data_process as dp
import ftpSidebaPre as ftpPre
import ftpSidebaPost as ftpPost
from tqdm import *
import time
import urllib2
import shutil

redis = StrictRedis(host=config.REDIS_HOST)
redis.delete(config.MESSAGES_KEY)
# celery = Celery(__name__)
# celery.config_from_object(celeryconfig)

app = Flask(__name__)
app.config.from_object(config)
assets.init_app(app)

app.config['SECRET_KEY'] = 'top-secret!'

app.config['SOCKETIO_CHANNEL'] = 'tail-message'
app.config['MESSAGES_KEY'] = 'tail'
app.config['CHANNEL_NAME'] = 'tail-channel'

app.config['SOCKETIO_CHANNEL_2'] = 'val-message'
app.config['MESSAGES_KEY_2'] = 'val'
app.config['CHANNEL_NAME_2'] = 'val-channel'

app.config['CELERY_BROKER_URL'] = 'redis://localhost:6379/0'
app.config['CELERY_RESULT_BACKEND'] = 'redis://localhost:6379/0'

# Initialize Celery