Ejemplo n.º 1
0
def create_app(config_class=Config):
    """
    Initiate application and register the routes and handlers to blueprint
    :param config_class: setting for sql
    :return: application initiate and blueprint mapping
    """
    app = Flask(__name__)

    app.config.from_object(config_class)
    search = Search()
    db.init_app(app)
    bcrypt.init_app(app)
    login_manager.init_app(app)

    search.init_app(app)
    mail.init_app(app)

    from docmanage.main.routes import main
    from docmanage.users.routes import users
    from docmanage.reports.routes import reports
    from docmanage.sub_menu.routes import sub_menu
    from docmanage.contacts.routes import contacts
    from docmanage.errors.handlers import errors
    from docmanage.analytics.routes import analytics

    app.register_blueprint(main)
    app.register_blueprint(users)
    app.register_blueprint(reports)
    app.register_blueprint(sub_menu)
    app.register_blueprint(contacts)
    app.register_blueprint(errors)
    app.register_blueprint(analytics)

    admin_control(app)

    return app
Ejemplo n.º 2
0
def create_app(config_class=Config):
    """
    Initiate application and register the routes and handlers to blueprint
    :param config_class: setting for sql
    :return: application initiate and blueprint mapping
    """
    app = Flask(__name__)

    app.config.from_object(config_class)
    search = Search()
    db.init_app(app)
    bcrypt.init_app(app)
    login_manager.init_app(app)

    search.init_app(app)
    mail.init_app(app)

    from recipe_scheduler.main.routes import main
    from recipe_scheduler.categories.routes import categories
    from recipe_scheduler.events.routes import events
    from recipe_scheduler.users.routes import users
    from recipe_scheduler.sub.routes import sub
    from recipe_scheduler.uploads.routes import uploads
    from recipe_scheduler.errors.handlers import errors

    app.register_blueprint(main)
    app.register_blueprint(categories)
    app.register_blueprint(events)
    app.register_blueprint(users)
    app.register_blueprint(sub)
    app.register_blueprint(uploads)
    app.register_blueprint(errors)

    admin_control(app)

    return app
Ejemplo n.º 3
0
# app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///myshop.db'
app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'postgresql://*****:*****@localhost:5433/shop'
app.config['SECRET_KEY'] = 'sdfsdfsdwrt435342sasddf'
basedir = os.path.abspath(os.path.dirname(__file__))
app.config['UPLOADED_PHOTOS_DEST'] = os.path.join(basedir, 'static/images')

photos = UploadSet('photos', IMAGES)
configure_uploads(app, photos)
patch_request_class(app)  # 16 megabytes

db = SQLAlchemy(app)
migrate = Migrate(app, db)
bcrypt = Bcrypt(app)
search = Search()
search.init_app(app)

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'customer_login'
login_manager.needs_refresh_message_category = 'danger'
login_manager.login_message = u"Please login first"

# Import these modules at the bottom to avoid circular import
if True:
    from shop.products import routes
    from shop.admin.routes import mgmt_bp
    from shop.carts import carts
    from shop.customers import routes
    app.register_blueprint(mgmt_bp)
Ejemplo n.º 4
0
import os

basedir = os.path.abspath(os.path.dirname(__file__))
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///db.db'
app.config['SECRET_KEY'] = "cdkil1k12h31hlasdj"  # al azar, no importa. la cosa es poner algo.
app.config['UPLOADED_PHOTOS_DEST'] = os.path.join(basedir, 'static/images')

photos = UploadSet('photos', IMAGES)
configure_uploads(app, photos)
patch_request_class(app)

db = SQLAlchemy(app)
bcrypt = Bcrypt(app)
search = Search()
search.init_app(app)  # inicializacion de la funcion search.

login_manager = LoginManager()
login_manager.init_app(app)
login_manager.login_view = 'customerLogin'
login_manager.needs_refresg_message_category = 'danger'
login_manager.login_message = "Conectese por favor"

from shop.admin import routes
from shop.products import routes
from shop.carts import cart
from shop.customers import routes
from shop.Marcas import routes
from shop.graphs import routes
Ejemplo n.º 5
0
from flask_sqlalchemy import SQLAlchemy
from flask_msearch import Search
from jieba.analyse import ChineseAnalyzer

#创建项目对象
app = Flask(__name__)

#加载配置文件内容
app.config.from_object('application.setting')  #模块下的setting文件名,不用加py后缀

#创建数据库对象
db = SQLAlchemy(app)

# 全文搜索
full_search = Search(analyzer=ChineseAnalyzer())
full_search.init_app(app)


def resp_200(data):
    return jsonify(data)


def resp_500(error_msg):
    return make_response(jsonify({'error': error_msg}), 500)


def resp_403(error_msg):
    return make_response(jsonify({'error': error_msg}), 403)


def resp_404(error_msg):