From 29a040464337c032b03bc086f8ad820f4e233e9a Mon Sep 17 00:00:00 2001 From: wangsiyuan <2392948297@qq.com> Date: Mon, 15 Apr 2024 11:34:00 +0800 Subject: [PATCH] Update huaweitest.py --- huaweitest.py | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/huaweitest.py b/huaweitest.py index 4fba0d4..091039c 100644 --- a/huaweitest.py +++ b/huaweitest.py @@ -16,11 +16,14 @@ async def root(request: Request): return "welcome to fastAPI!" +def random_bool(): + return "true" if random.random() > 0.5 else "false" + + @app.get("/script/getscriparam") async def getscriparam(request: Request): # 获取当前时间 now = datetime.now() - # 格式化时间为 年-月-日 时:分:秒 的格式 formatted_now = now.strftime("%Y-%m-%d %H:%M:%S") print(f"请求IP地址: {request.client.host},请求时间{formatted_now},请求路径: /script/getscriparam") @@ -30,7 +33,9 @@ async def getscriparam(request: Request): "pagesToViewPerSession": {"from": 2, "to": 3}, "sessionsPerUser": {"from": 2, "to": 3}, "ctr": {"from": 0.03, "to": 0.05}, - "shouldDoClick": "true" + "shouldDoClick": "true", + "shouldExecute": "true", + "shouldBounce": "false", } 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/") async def get_account(request: Request): server_token = "cT&Ur7AciCgL6P$2u!^mauI05r6jcD$A"