prince1604 commited on
Commit
fc24f5c
·
1 Parent(s): 3176f9b

Add Postman collection guide and fix URL normalization

Browse files
Files changed (2) hide show
  1. POSTMAN_COLLECTION.md +171 -0
  2. api.py +1 -0
POSTMAN_COLLECTION.md ADDED
@@ -0,0 +1,171 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Postman Collection - Hugging Face Deployment
2
+ **Base URL**: `https://ubuntu593-alt-scraper-api.hf.space`
3
+
4
+ ---
5
+
6
+ ## 1️⃣ Health Check
7
+ **Simple uptime check**
8
+
9
+ - **Method**: `GET`
10
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/health`
11
+ - **Expected Response**:
12
+ ```json
13
+ {
14
+ "status": "alive"
15
+ }
16
+ ```
17
+
18
+ ---
19
+
20
+ ## 2️⃣ System Status
21
+ **Check server region, latency, and domain connectivity**
22
+
23
+ - **Method**: `GET`
24
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/status?domain=https://wpengine.com/`
25
+ - **Parameters**:
26
+ - `domain` (optional): Target domain to test connectivity
27
+ - **Expected Response**:
28
+ ```json
29
+ {
30
+ "region": "Frankfurt, DE",
31
+ "latency": 45,
32
+ "status": "operational",
33
+ "engine": "AutoAlt Neural v2"
34
+ }
35
+ ```
36
+
37
+ ---
38
+
39
+ ## 3️⃣ Start a New Scan
40
+ **Initiate async crawl job**
41
+
42
+ - **Method**: `POST`
43
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/scanstart`
44
+ - **Headers**:
45
+ - `Content-Type: application/json`
46
+ - **Body** (raw JSON):
47
+ ```json
48
+ {
49
+ "domain": "https://wpengine.com/",
50
+ "limit": 25
51
+ }
52
+ ```
53
+ - **Expected Response**:
54
+ ```json
55
+ {
56
+ "job_id": "abc123-def456-..."
57
+ }
58
+ ```
59
+ **⚠️ Save this `job_id` for the next steps!**
60
+
61
+ ---
62
+
63
+ ## 4️⃣ Check Scan Progress
64
+ **Poll for real-time updates**
65
+
66
+ ### Option A: Path Parameter
67
+ - **Method**: `GET`
68
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/progress/{job_id}`
69
+ - Replace `{job_id}` with the actual ID from step 3
70
+
71
+ ### Option B: Query Parameter (Easier for browser testing)
72
+ - **Method**: `GET`
73
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/progress?job_id=YOUR_JOB_ID_HERE`
74
+
75
+ **Expected Response**:
76
+ ```json
77
+ {
78
+ "status": "running",
79
+ "percent": 60,
80
+ "pages_scanned": 15,
81
+ "images_found": 87,
82
+ "message": "Scanning: https://wpengine.com/about",
83
+ "elapsed_seconds": 12,
84
+ "eta_seconds": 8,
85
+ "error": null
86
+ }
87
+ ```
88
+
89
+ **Status Values**: `pending`, `running`, `done`, `error`
90
+
91
+ ---
92
+
93
+ ## 5️⃣ Get Final Results
94
+ **Retrieve complete JSON report (once status is `done`)**
95
+
96
+ ### Option A: Path Parameter
97
+ - **Method**: `GET`
98
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/result/{job_id}`
99
+
100
+ ### Option B: Query Parameter
101
+ - **Method**: `GET`
102
+ - **URL**: `https://ubuntu593-alt-scraper-api.hf.space/api/result?job_id=YOUR_JOB_ID_HERE`
103
+
104
+ **Expected Response**:
105
+ ```json
106
+ {
107
+ "summary": {
108
+ "total_pages_scanned": 25,
109
+ "total_images_found": 145,
110
+ "total_images_missing_alt": 23,
111
+ "total_images_poor_quality": 5,
112
+ "total_pages_discovered": 50,
113
+ "blocked_reason": null,
114
+ "crawl_blocked": false
115
+ },
116
+ "details": [ ... ]
117
+ }
118
+ ```
119
+
120
+ ---
121
+
122
+ ## 🧪 Complete Test Flow (Copy to Postman)
123
+
124
+ ### Test 1: Health Check
125
+ ```bash
126
+ curl https://ubuntu593-alt-scraper-api.hf.space/health
127
+ ```
128
+
129
+ ### Test 2: System Status
130
+ ```bash
131
+ curl "https://ubuntu593-alt-scraper-api.hf.space/api/status?domain=https://wpengine.com/"
132
+ ```
133
+
134
+ ### Test 3: Start Scan
135
+ ```bash
136
+ curl -X POST "https://ubuntu593-alt-scraper-api.hf.space/api/scanstart" \
137
+ -H "Content-Type: application/json" \
138
+ -d '{"domain": "https://wpengine.com/", "limit": 25}'
139
+ ```
140
+
141
+ ### Test 4: Progress (use job_id from Test 3)
142
+ ```bash
143
+ curl "https://ubuntu593-alt-scraper-api.hf.space/api/progress?job_id=PASTE_JOB_ID"
144
+ ```
145
+
146
+ ### Test 5: Result (when status = done)
147
+ ```bash
148
+ curl "https://ubuntu593-alt-scraper-api.hf.space/api/result?job_id=PASTE_JOB_ID"
149
+ ```
150
+
151
+ ---
152
+
153
+ ## ⚠️ Common Mistakes to Avoid
154
+
155
+ 1. **Don't use `limit` parameter on `/api/status`** ❌
156
+ - ❌ Wrong: `/api/status?domain=...&limit=25`
157
+ - ✅ Right: `/api/status?domain=...`
158
+
159
+ 2. **Use POST (not GET) for `/api/scanstart`** ❌
160
+ - ❌ Wrong: GET request
161
+ - ✅ Right: POST with JSON body
162
+
163
+ 3. **Don't forget to URL-encode the domain parameter** ⚠️
164
+ - If testing in browser, use `https%3A%2F%2Fwpengine.com%2F`
165
+ - Postman/curl handle this automatically
166
+
167
+ ---
168
+
169
+ ## 🎯 Quick Postman Import
170
+
171
+ Create a new Postman collection and add these 5 requests with the URLs above. Test them in order!
api.py CHANGED
@@ -190,6 +190,7 @@ def health_check():
190
 
191
  @app.get("/api/status")
192
  def get_system_status(domain: Optional[str] = None):
 
193
  stats = SystemMonitor.get_system_stats(target_url=domain)
194
  return stats
195
 
 
190
 
191
  @app.get("/api/status")
192
  def get_system_status(domain: Optional[str] = None):
193
+ # If a domain is provided, we check its connectivity specifically
194
  stats = SystemMonitor.get_system_stats(target_url=domain)
195
  return stats
196