from flask import Flask from flask_restx import Api from auth import Auth from action import Action from apscheduler.schedulers.background import BackgroundScheduler from apscheduler.triggers.interval import IntervalTrigger from tools.weather_agency_api.weather_api import update_weather_info_to_today from tools.algo.SARIMA import sarima app = Flask(__name__) print("Api Start") api = Api( app, version='0.1', title="trafficagent", description="API Server", terms_url="/", contact="dhlim@takensoft.co.kr", license="MIT") scheduler = BackgroundScheduler() scheduler.start() # Schedule task_function to be called every 6 hours scheduler.add_job( func=update_weather_info_to_today, trigger=IntervalTrigger(hours=6), args=("data/weather/weather_data.csv",), # comma to make it a tuple, so that python won't confuse this as a list of char id='weather_data_update', name='update weather time every 6 hours', replace_existing=True ) scheduler.add_job( func=sarima, trigger=IntervalTrigger(hours=6), args=("data/weather/weather_data.csv",), # comma to make it a tuple, so that python won't confuse this as a list of char id='weather_data_update', name='update weather time every 6 hours', replace_existing=True ) api.add_namespace(Action, '/action') update_weather_info_to_today("data/weather/weather_data.csv") sarima("data/weather/weather_data.csv") api.add_namespace(Auth, '/auth') print("Api Add Auth") if __name__ == "__main__": try: app.run(debug=False, host='0.0.0.0', port=8080) except: scheduler.shutdown() print("Flask Start")