Exemple #1
0
def init_ext(app):
    # 初始化数据库
    init_db(app)
    # 初始化Api接口
    init_api(app)
    # 初始化邮箱模块
    mail.init_app(app)
    # 初始化缓存
    cache.init_app(app)
Exemple #2
0
def init_ext(app):
    #  初始化数据库
    init_db(app)

    #  初始化api接口
    init_api(app)
    #  初始化邮箱模块
    mail.init_app(app)
    # 初始化cache模块
    cache.init_app(app)
Exemple #3
0
def create_app(config=SQLiteConfig):
    app = Flask(__name__, static_folder=STATIC_FOLDER, template_folder=TEMPLATES_FOLDER)
    app.config.from_object(SQLiteConfig)

    init_db(app)
    init_users(app)
    init_posts(app)
    init_main(app)
    init_errors(app)
    init_ext(app)
    return app
Exemple #4
0
from flask import Flask
from flask_script import Manager

from App.models import init_db
from App.views import blue

app = Flask(__name__)

app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:7986805@localhost:3306/python1804FlaskModel'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False

app.register_blueprint(blueprint=blue)
init_db(app)
manager = Manager(app=app)

if __name__ == '__main__':
    manager.run()
Exemple #5
0
from flask import Flask
from flask_script import Manager
from App.views import blue
from App.models import init_db

app = Flask(__name__)
app.register_blueprint(blue)
manager = Manager(app=app)

# sqlite数据库配置,下面3条配置
# app.config['SQLALCHEMY_DATABASE_URI']='sqlite:///sqlite3.db'
app.config[
    'SQLALCHEMY_DATABASE_URI'] = 'mysql+pymysql://root:123456@localhost:3306/xzlmark'
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False
init_db(app)  # 初始化db

if __name__ == '__main__':
    manager.run()
Exemple #6
0
from flask import Flask
from flask_script import Manager
from App.views import blue as blue1
from App.models import init_db
app = Flask(__name__)
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///sqlite3.db'  #連接DB
app.config['SQLALCHEMY_TRACK_MODIFICATIONS'] = False  #更好的兼容性,不然會有警告
app.register_blueprint(blueprint=blue1)

#db = SQLAlchemy(app=app)#app創建一個SQLalchemy
#但是這樣導入DB會造成循環導入有錯誤
#故直接在model.py導入
init_db(app)  #調用modeel.py的init_db把app傳過去   #記得要import

manager = Manager(app=app)

if __name__ == '__main__':
    manager.run()