from flask_apscheduler import APScheduler
class Config(object):
JOBS=[
{
'id':'job',
'func':'__main__:job', // 需要执行的函数job
'trigger':'cron', // corn 是执行定时任务的触发器类型
'hour':9,
'minute':25
}
]
app = Flask(__name__)
app.config['DEBUG'] = True
app.config.from_object(Config())
CORS(app, supports_credentials=True)
os.environ['NLS_LANG'] = 'SIMPLIFIED CHINESE_CHINA.UTF8'
def job()
print("dingshirenwu")
if __name__ == "__main__":
# print(select_modeli())
scheduler=APScheduler()
scheduler.init_app(app)
scheduler.start()
app.run(host='127.0.0.1', port='5678',use_reloader=False)
如果 不加 use_reloader=False,定时任务的会执行两次