File size: 2,879 Bytes
504b397
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
# Hugging Face Spaces Deployment

This guide shows how to deploy OhMyCaptcha on **Hugging Face Spaces** using a Docker-based Space.

## When to choose Hugging Face Spaces

Use Hugging Face Spaces when you want:

- a simple public or private demo deployment
- a UI-driven hosting workflow
- easy secret management inside the Space settings
- a Docker-based environment without managing a VPS yourself

## 1. Prepare the repository

Make sure your repository includes:

- `Dockerfile.render`
- `main.py`
- `requirements.txt`
- the `src/` application package

For Hugging Face Spaces, the current Dockerfile can be reused as a starting point because it already installs Python dependencies and Playwright Chromium.

## 2. Create a Docker Space

In Hugging Face:

1. Create a new **Space**.
2. Choose **Docker** as the SDK.
3. Select visibility according to your needs.
4. Connect the Space to this repository or upload the project files.

## 3. Configure secrets and variables

In the Space settings, add the following secrets:

- `CLIENT_KEY`
- `CAPTCHA_API_KEY`

Add or override variables as needed:

- `CAPTCHA_BASE_URL`
- `CAPTCHA_MODEL`
- `CAPTCHA_MULTIMODAL_MODEL`
- `BROWSER_HEADLESS=true`
- `BROWSER_TIMEOUT=30`
- `SERVER_PORT=7860`

Hugging Face Spaces typically expose applications on port `7860`, so set `SERVER_PORT=7860`.

## 4. Confirm the startup command

The container should start the app with:

```bash
python main.py
```

The entrypoint already respects environment-based port configuration.

## 5. Wait for the build to finish

After the Space starts building:

- watch the build logs
- confirm dependency installation finishes successfully
- confirm Playwright Chromium installs successfully
- wait for the app to enter the running state

## 6. Validate the deployment

Once the Space is live, verify:

### Root endpoint

```bash
curl https://<your-space-subdomain>.hf.space/
```

### Health endpoint

```bash
curl https://<your-space-subdomain>.hf.space/api/v1/health
```

### Create a detector task

```bash
curl -X POST https://<your-space-subdomain>.hf.space/createTask \
  -H "Content-Type: application/json" \
  -d '{
    "clientKey": "your-client-key",
    "task": {
      "type": "RecaptchaV3TaskProxyless",
      "websiteURL": "https://antcpt.com/score_detector/",
      "websiteKey": "6LcR_okUAAAAAPYrPe-HK_0RULO1aZM15ENyM-Mf",
      "pageAction": "homepage"
    }
  }'
```

## Operational notes

- Hugging Face Spaces are convenient, but cold starts and resource limits can affect Playwright-based workloads.
- Browser automation can be more sensitive to shared-hosting environments than standard API-only apps.
- If you need stricter runtime control, use Render or your own infrastructure.

## Recommended usage

Hugging Face Spaces is best suited for:

- evaluation
- demos
- low-volume internal usage
- fast public documentation-linked deployment