Compare commits

..

2 Commits

Author SHA1 Message Date
wangsiyuan fba2513b5f 创建 huaweitest.py 2024-02-19 17:15:26 +08:00
wangsiyuan 48074edc21 创建 huaweitest.cpython-311.pyc 2024-02-19 17:15:23 +08:00
2 changed files with 41 additions and 0 deletions

Binary file not shown.

41
huaweitest.py Normal file
View File

@ -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": {}
}