Update huaweitest.py
parent
57714ddd21
commit
29a0404643
|
|
@ -16,11 +16,14 @@ async def root(request: Request):
|
||||||
return "welcome to fastAPI!"
|
return "welcome to fastAPI!"
|
||||||
|
|
||||||
|
|
||||||
|
def random_bool():
|
||||||
|
return "true" if random.random() > 0.5 else "false"
|
||||||
|
|
||||||
|
|
||||||
@app.get("/script/getscriparam")
|
@app.get("/script/getscriparam")
|
||||||
async def getscriparam(request: Request):
|
async def getscriparam(request: Request):
|
||||||
# 获取当前时间
|
# 获取当前时间
|
||||||
now = datetime.now()
|
now = datetime.now()
|
||||||
|
|
||||||
# 格式化时间为 年-月-日 时:分:秒 的格式
|
# 格式化时间为 年-月-日 时:分:秒 的格式
|
||||||
formatted_now = now.strftime("%Y-%m-%d %H:%M:%S")
|
formatted_now = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
print(f"请求IP地址: {request.client.host},请求时间{formatted_now},请求路径: /script/getscriparam")
|
print(f"请求IP地址: {request.client.host},请求时间{formatted_now},请求路径: /script/getscriparam")
|
||||||
|
|
@ -30,7 +33,9 @@ async def getscriparam(request: Request):
|
||||||
"pagesToViewPerSession": {"from": 2, "to": 3},
|
"pagesToViewPerSession": {"from": 2, "to": 3},
|
||||||
"sessionsPerUser": {"from": 2, "to": 3},
|
"sessionsPerUser": {"from": 2, "to": 3},
|
||||||
"ctr": {"from": 0.03, "to": 0.05},
|
"ctr": {"from": 0.03, "to": 0.05},
|
||||||
"shouldDoClick": "true"
|
"shouldDoClick": "true",
|
||||||
|
"shouldExecute": "true",
|
||||||
|
"shouldBounce": "false",
|
||||||
}
|
}
|
||||||
|
|
||||||
return data
|
return data
|
||||||
|
|
@ -90,6 +95,23 @@ async def report_chrome_crash(id: str, timestamp: str = Query(None)):
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/script/uploaddata")
|
||||||
|
async def upload_ads_status(impressions: str, clicks: str):
|
||||||
|
# 获取当前时间
|
||||||
|
now = datetime.now()
|
||||||
|
|
||||||
|
# 格式化时间为 年-月-日 时:分:秒 的格式
|
||||||
|
formatted_now = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
|
||||||
|
# 假设这里记录失败原因到日志或数据库
|
||||||
|
print(f"Time: {formatted_now}, impressions: {impressions}, clicks: {clicks}") # 实际应用中应使用更专业的日志记录方式
|
||||||
|
return {
|
||||||
|
"code": 0,
|
||||||
|
"msg": "ok",
|
||||||
|
"data": {}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@app.post("/api/account/")
|
@app.post("/api/account/")
|
||||||
async def get_account(request: Request):
|
async def get_account(request: Request):
|
||||||
server_token = "cT&Ur7AciCgL6P$2u!^mauI05r6jcD$A"
|
server_token = "cT&Ur7AciCgL6P$2u!^mauI05r6jcD$A"
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue