添加设备重置功能
This commit is contained in:
parent
ffc5469f91
commit
10d8af8ade
19
main.py
19
main.py
|
|
@ -8,7 +8,8 @@ from typing import Dict, Any, Optional, List
|
||||||
from fastapi import FastAPI, HTTPException, Depends
|
from fastapi import FastAPI, HTTPException, Depends
|
||||||
|
|
||||||
from public_function.public_func import read_config
|
from public_function.public_func import read_config
|
||||||
from model.model import AccountCreate, AccountUpdate, CrawlerTask, AccountDelete, DataReceive
|
from model.model import CrawlerTask, AccountDelete, DataReceive
|
||||||
|
from model.model import AccountCreate, AccountUpdate, DeviceResetData
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
@ -135,5 +136,21 @@ async def crawler_task(task_data: CrawlerTask, task_manager: Any = Depends(get_t
|
||||||
raise HTTPException(status_code=500, detail="获取数据失败;失败原因{}".format(e))
|
raise HTTPException(status_code=500, detail="获取数据失败;失败原因{}".format(e))
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/device_reset", summary="爬虫任务调用接口")
|
||||||
|
async def device_reset(task_data: CrawlerTask, reset_manager: Any = Depends(get_reset_manager)):
|
||||||
|
"""设备重置接口"""
|
||||||
|
try:
|
||||||
|
params = task_data.dict()
|
||||||
|
params['task_id'] = uuid.uuid4().hex
|
||||||
|
# 将任务记录到mysql
|
||||||
|
# result = await task_manager.task_distribution(params)
|
||||||
|
# if result:
|
||||||
|
# return {"code": 200, "message": "<UNK>", "data": result}
|
||||||
|
raise HTTPException(status_code=404, detail="抓取商品数据失败,请重新尝试")
|
||||||
|
except Exception as e:
|
||||||
|
print(f"<UNK>: {e}")
|
||||||
|
raise HTTPException(status_code=500, detail="获取数据失败;失败原因{}".format(e))
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
uvicorn.run(app)
|
uvicorn.run(app)
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue