加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
app.py 1.39 KB
一键复制 编辑 原始数据 按行查看 历史
TaurusXin 提交于 2021-04-27 11:48 . fix: log level
import datetime
import logging
from flask import Flask
from database import db
from config import DevConfig
from course.course_blueprint import course_blue
from user.user_blueprint import user_blue
from index import index_blue
from admin.admin_blueprint import admin_blueprint
from order.order_blueprint import order_blueprint
from file.file_blueprint import file_blueprint
from flask_apscheduler import APScheduler
# 注册全局flask
app = Flask(__name__)
app.config.from_object(DevConfig)
# 初始化定时器
scheduler = APScheduler()
scheduler.init_app(app)
scheduler.start()
# 注册数据库
db.init_app(app)
# 注册蓝图
app.register_blueprint(course_blue)
app.register_blueprint(user_blue)
app.register_blueprint(index_blue)
app.register_blueprint(admin_blueprint, url_prefix='/admin')
app.register_blueprint(order_blueprint, url_prefix='/api')
app.register_blueprint(file_blueprint, url_prefix='/file')
logging.basicConfig(level=logging.DEBUG, format=' %(asctime)s - %(levelname)s - %(message)s',
filename='/root/miniapp-' + datetime.datetime.now().strftime('%Y-%m-%d-%H-%M-%S') + '.log')
@app.route('/')
def hello_world():
return '<h1>Hello World!</h1>', 200
if __name__ == '__main__':
logging.info('Running miniapp backend at http://localhost:5000/...')
logging.info('Warning: You are running this project in development mode!')
app.run(host='0.0.0.0', port=5000)
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化