diff --git a/huaweitest.py b/huaweitest.py new file mode 100644 index 0000000..7b04a52 --- /dev/null +++ b/huaweitest.py @@ -0,0 +1,41 @@ +from fastapi import FastAPI + +app = FastAPI() + + +@app.get("/") +async def root(): + return "welcome to fastAPI!" + + +@app.get("/script/getscriparam") +async def getscriparam(): + data = {"bounceRate": {"from": 0.3, "to": 0.4}, "ctr": {"from": 0.03, "to": 0.05}, + "interaction": {"from": 20, "to": 30}, + "pagesToViewPerSession": {"from": 2, "to": 3}, "sessionsPerUser": {"from": 2, "to": 3}} + return { + "code": 0, + "msg": "ok", + "data": data + } + + +@app.get("/script/success") +async def do_success(): + data = {} + return { + "code": 0, + "msg": "ok", + "data": data + } + + +@app.get("/script/failed") +async def do_failed(reason: str = None): + # 假设这里记录失败原因到日志或数据库 + print(f"失败原因: {reason}") # 实际应用中应使用更专业的日志记录方式 + return { + "code": 0, + "msg": "ok", + "data": {} + }