import asyncio
import os
from mycode.TaskManager import g_TaskM
from web import create_app
from hypercorn.asyncio import serve
from hypercorn.config import Config

async def run_quart_app():
    app = create_app()
    config = Config()
    config.bind = ["0.0.0.0:5001"]
    config.use_reloader = True  # 启用热重载
    config.reload_include_patterns = ["*.py", "templates/*", "static/*"]  # 监控模板和静态文件
    await serve(app, config)


#-------------------测试相关----------------------


# Press the green button in the gutter to run the script.
if __name__ == '__main__':
    print(f"Current working directory (run.py): {os.getcwd()}")
    #加载未完成的工作继续执行
    g_TaskM.load_tasks()
    #启动web项目--hypercorn
    asyncio.run(run_quart_app())
    #Uvicom启动
    #uvicorn.run("run:app", host="0.0.0.0", port=5001, workers=4, reload=True)