chore: добавил парсинг запроса

This commit is contained in:
protokey committed 2026-09-08 16:56:56 +04:00
1 parent 522091b084
commit 0602d89012
3 files changed
+48 -5

No files matched your search

+1 -1
View File
@@ -72,7 +72,7 @@ X-API-Key: <key>
], ],
"proxy": "socks5://user:pass@host:port", "proxy": "socks5://user:pass@host:port",
"screen": "1280x920", "screen": "1280x920",
"user-agent": "Firefox", "user_agent": "Firefox",
"timeout": 120 "timeout": 120
} }
``` ```
+23 -4
View File
@@ -1,13 +1,32 @@
from fastapi import FastAPI from fastapi import FastAPI
from pydantic import BaseModel
class ActionRequest(BaseModel):
type: str
selector: str | None = None
value: str | None = None
timeout: int | None = None
class SolveRequest(BaseModel):
url: str
proxy: str
actions: list[ActionRequest]
timeout: int | None = None
screen: str | None = None
user_agent: str | None = None
captcha: str | None = None
app = FastAPI() app = FastAPI()
@app.get("/") @app.get("/")
async def root(): async def root():
return {"message": "Hello World"} return {"message": "Hello World"}
@app.get("/hello/{name}") @app.post("/v1/solve")
async def say_hello(name: str): async def solve(payload: SolveRequest):
return {"message": f"Hello {name}"} return {"message": payload.model_dump(exclude_none=True)}
+24
View File
@@ -9,3 +9,27 @@ GET http://127.0.0.1:8000/hello/User
Accept: application/json Accept: application/json
### ###
POST http://127.0.0.1:8000/v1/solve
Accept: application/json
Content-Type: application/json
X-API-Key: <key>
{
"captcha": "token",
"url": "https://example.com/login",
"actions": [
{"type": "fill", "selector": "#email", "value": "user@example.com"},
{"type": "fill", "selector": "#password", "value": "..."},
{"type": "mouse_move", "selector": "#submit"},
{"type": "click", "selector": "#submit"},
{"type": "wait_for", "selector": ".dashboard", "timeout": 30}
],
"proxy": "socks5://user:pass@host:port",
"screen": "1280x920",
"user_agent": "Firefox",
"timeout": 120
}
###