Update huaweitest.py
parent
fb3d7190b7
commit
8cc72f50ee
|
|
@ -1,5 +1,6 @@
|
||||||
from fastapi import FastAPI, Query, Request
|
from fastapi import FastAPI, Query, Request,HTTPException
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
|
import random
|
||||||
|
|
||||||
app = FastAPI()
|
app = FastAPI()
|
||||||
|
|
||||||
|
|
@ -22,7 +23,7 @@ async def getscriparam(request: Request):
|
||||||
|
|
||||||
# 格式化时间为 年-月-日 时:分:秒 的格式
|
# 格式化时间为 年-月-日 时:分:秒 的格式
|
||||||
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},请求路径: /")
|
print(f"请求IP地址: {request.client.host},请求时间{formatted_now},请求路径: /script/getscriparam")
|
||||||
data = {
|
data = {
|
||||||
"interaction": {
|
"interaction": {
|
||||||
"from": 20,
|
"from": 20,
|
||||||
|
|
@ -58,7 +59,8 @@ async def do_success(request: Request):
|
||||||
client_host = request.client.host
|
client_host = request.client.host
|
||||||
|
|
||||||
# 打印上报成功的时间和IP地址
|
# 打印上报成功的时间和IP地址
|
||||||
print(f"请求IP地址: {client_host},上报成功时间: {current_time}")
|
# print(f"请求IP地址: {client_host},上报成功时间: {current_time}")
|
||||||
|
print(f"请求IP地址: {client_host},请求时间{current_time},请求路径: /script/success")
|
||||||
|
|
||||||
data = {}
|
data = {}
|
||||||
return {
|
return {
|
||||||
|
|
@ -100,3 +102,34 @@ async def report_chrome_crash(id: str, timestamp: str = Query(None)):
|
||||||
"msg": "ok",
|
"msg": "ok",
|
||||||
"data": {}
|
"data": {}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@app.post("/api/account/")
|
||||||
|
async def get_account(request: Request):
|
||||||
|
server_token = "cT&Ur7AciCgL6P$2u!^mauI05r6jcD$A"
|
||||||
|
accounts = [
|
||||||
|
{"account": "reedavice8@gmail.com", "password": "L906lTeTlpelaq",
|
||||||
|
"auxiliary_mailbox": "tcmuffin56@mailexpire.com"},
|
||||||
|
{"account": "annist95g@gmail.com", "password": "28CUxUmygURereJ",
|
||||||
|
"auxiliary_mailbox": "b1youngster983@yahoo.ie"},
|
||||||
|
{"account": "vr8607864@gmail.com", "password": "J945YgaX", "auxiliary_mailbox": "sbqunmetal3@xtra.co.nz"},
|
||||||
|
{"account": "ShimoGuagliardo537@gmail.com", "password": "94Ss9YYx3",
|
||||||
|
"auxiliary_mailbox": "spigelmyerhalalikyzd185@yawua.us"},
|
||||||
|
]
|
||||||
|
|
||||||
|
# 从请求头中获取token
|
||||||
|
token = request.headers.get('Authorization')
|
||||||
|
# 获取当前时间
|
||||||
|
now = datetime.now()
|
||||||
|
# 格式化时间
|
||||||
|
formatted_now = now.strftime("%Y-%m-%d %H:%M:%S")
|
||||||
|
print(f"请求IP地址: {request.client.host}, 请求时间: {formatted_now}, 请求token: {token}, 请求路径: /api/account/")
|
||||||
|
|
||||||
|
# 检查token是否存在且匹配
|
||||||
|
if not token or token != server_token:
|
||||||
|
# 如果token不正确,返回401未授权状态
|
||||||
|
raise HTTPException(status_code=401, detail="Unauthorized")
|
||||||
|
|
||||||
|
# 随机选择一个账户信息返回
|
||||||
|
selected_account = random.choice(accounts)
|
||||||
|
return selected_account
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue