From 0602d8901246fe28805c0da46b203b84e7b44381 Mon Sep 17 00:00:00 2001 From: protokey Date: Tue, 8 Sep 2026 16:56:56 +0400 Subject: [PATCH] =?UTF-8?q?chore:=20=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=B8?= =?UTF-8?q?=D0=BB=20=D0=BF=D0=B0=D1=80=D1=81=D0=B8=D0=BD=D0=B3=20=D0=B7?= =?UTF-8?q?=D0=B0=D0=BF=D1=80=D0=BE=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- src/main.py | 27 +++++++++++++++++++++++---- tests/test_main.http | 24 ++++++++++++++++++++++++ 3 files changed, 48 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 1087a7f..912c7cd 100644 --- a/README.md +++ b/README.md @@ -72,7 +72,7 @@ X-API-Key: ], "proxy": "socks5://user:pass@host:port", "screen": "1280x920", - "user-agent": "Firefox", + "user_agent": "Firefox", "timeout": 120 } ``` diff --git a/src/main.py b/src/main.py index 6d7c6d9..e77f49f 100644 --- a/src/main.py +++ b/src/main.py @@ -1,13 +1,32 @@ 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.get("/") async def root(): - return {"message": "Hello World"} + return {"message": "Hello World"} -@app.get("/hello/{name}") -async def say_hello(name: str): - return {"message": f"Hello {name}"} +@app.post("/v1/solve") +async def solve(payload: SolveRequest): + return {"message": payload.model_dump(exclude_none=True)} diff --git a/tests/test_main.http b/tests/test_main.http index a2d81a9..8566871 100644 --- a/tests/test_main.http +++ b/tests/test_main.http @@ -9,3 +9,27 @@ GET http://127.0.0.1:8000/hello/User Accept: application/json ### + +POST http://127.0.0.1:8000/v1/solve +Accept: application/json +Content-Type: application/json +X-API-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 +} + +###