__init__.py 1.6 KB
import requests
import threading
from flask import Flask
from flask_babel import Babel
from config import Config
import logging
from logging.handlers import RotatingFileHandler,TimedRotatingFileHandler

# from flask_socketio import SocketIO

def setup_log():
    # 设置日志的记录等级
    logging.basicConfig(level=Config.LOG_LEVEL)  # 调试debug级
    # 创建日志记录器,指明日志保存的路径、每个日志文件的最大大小、保存的日志文件个数上限
    file_log_handler = RotatingFileHandler(Config.LOG_FOLDER, maxBytes=1024 * 1024 * 100, backupCount=10)
    # 创建日志记录的格式 日志等级 输入日志信息的文件名 行数 日志信息
    # log_file_handler = TimedRotatingFileHandler(filename='logs/smartshelf.log', when="D", interval=1, backupCount=3)
    formatter = logging.Formatter('%(asctime)s :  %(message)s')
    # 为刚创建的日志记录器设置日志记录格式
    file_log_handler.setFormatter(formatter)
    # 为全局的日志工具对象(flask app使用的)添加日志记录器
    logging.getLogger().addHandler(file_log_handler)

Serl=None

setup_log()
app = Flask(__name__)
babel = Babel(app)
app.config.from_object(Config)

LANGUAGES = {
        "zh": "Chinese",
        "en": "English",
        "ja": "Japanese"
}

from app import induction_post,induction_test,induction_admin,induction_config,autoback,qr_code,scan_collection
import time
def s():
    data = {'key1':'value1','key2':'value2'}
    time.sleep(2)
    requests.post("http://127.0.0.1:5000/stoppost",data)
    time.sleep(2)
    requests.post("http://127.0.0.1:5000/startpost",data)

t =threading.Thread(target=s)
t.start()
# 	return app