Compare commits
2 Commits
ffc5469f91
...
0f6c06ada1
| Author | SHA1 | Date |
|---|---|---|
|
|
0f6c06ada1 | |
|
|
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 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()
|
||||
|
||||
|
|
@ -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))
|
||||
|
||||
|
||||
@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__':
|
||||
uvicorn.run(app)
|
||||
|
|
|
|||
|
|
@ -35,3 +35,7 @@ class DataReceive(BaseModel):
|
|||
goods_id: str = Field(..., description="商品ID")
|
||||
country: str = Field(..., description="国家")
|
||||
goods_info: Dict[str, Any] = Field(..., description="商品信息")
|
||||
|
||||
|
||||
class DeviceResetData(BaseModel):
|
||||
device_id: str = Field(..., description="设备ID")
|
||||
|
|
|
|||
Loading…
Reference in New Issue