1 Star 1 Fork 0

宗布 / FlaskDemo

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
app.py 930 Bytes
AI 代码解读
一键复制 编辑 原始数据 按行查看 历史
houyi 提交于 2023-12-20 16:51 . 项目初始化
import logging
from flask import Flask
import auth
import blog
from config import BaseConfig
from extensions import db
from flask_session import Session
def create_app():
"""Create and configure an instance of the Flask application."""
app = Flask(__name__, instance_relative_config=True)
app.config.from_object(BaseConfig)
stream_handler = logging.StreamHandler()
stream_handler.setLevel(logging.DEBUG)
app.logger.addHandler(stream_handler)
# initialize Flask-SQLAlchemy
db.init_app(app)
# apply the blueprints to the app
app.register_blueprint(auth.bp)
app.register_blueprint(blog.bp)
# make "index" point at "/", which is handled by "blog.index"
app.add_url_rule("/", endpoint="index")
with app.app_context():
db.create_all()
sess = Session()
sess.init_app(app)
return app
if __name__ == '__main__':
app = create_app()
app.run()
Python
1
https://gitee.com/mkee/flask-demo.git
git@gitee.com:mkee/flask-demo.git
mkee
flask-demo
FlaskDemo
master

搜索帮助