first commit
This commit is contained in:
51
main.py
Normal file
51
main.py
Normal file
@@ -0,0 +1,51 @@
|
||||
import os
|
||||
import sys
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from pathlib import Path
|
||||
|
||||
BASE_DIR = Path(__file__).parent.parent
|
||||
sys.path.insert(0, str(BASE_DIR))
|
||||
|
||||
from wechat_auto.config import settings
|
||||
from wechat_auto.api.trigger import router as trigger_router
|
||||
from wechat_auto.utils.logger import logger
|
||||
|
||||
|
||||
app = FastAPI(
|
||||
title="微信小程序活动发布自动化系统",
|
||||
description="使用pyautogui + Qwen AI双方案自动化发布小程序活动",
|
||||
version="1.0.0"
|
||||
)
|
||||
|
||||
app.include_router(trigger_router)
|
||||
|
||||
|
||||
@app.on_event("startup")
|
||||
async def startup_event():
|
||||
logger.info("=" * 50)
|
||||
logger.info("微信小程序活动发布自动化系统启动")
|
||||
logger.info(f"服务地址: http://{settings.host}:{settings.port}")
|
||||
logger.info(f"API文档: http://{settings.host}:{settings.port}/docs")
|
||||
logger.info("=" * 50)
|
||||
|
||||
|
||||
@app.on_event("shutdown")
|
||||
async def shutdown_event():
|
||||
logger.info("服务关闭")
|
||||
|
||||
|
||||
def main():
|
||||
os.environ.setdefault("DISPLAY", os.getenv("DISPLAY", ":0"))
|
||||
|
||||
uvicorn.run(
|
||||
"wechat_auto.main:app",
|
||||
host=settings.host,
|
||||
port=settings.port,
|
||||
reload=False,
|
||||
log_level=settings.log_level.lower()
|
||||
)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user