dromero-nttd commited on
Commit
d0d0769
·
1 Parent(s): a2e3bb6

Add remote test and Postman collection

Browse files
README.md CHANGED
@@ -84,6 +84,16 @@ docker run -p 7860:7860 --env-file .env ddgs-api
84
 
85
  Note: `certif_zscaler/` is excluded from the Docker build context via `.dockerignore`. Zscaler is only used locally when `USE_LOCAL_ZSCALER_CERT=true`. HF deployments will not load Zscaler certs.
86
 
 
 
 
 
 
 
 
 
 
 
87
  ## Environment variables
88
 
89
  - `DDGS_REGION`
 
84
 
85
  Note: `certif_zscaler/` is excluded from the Docker build context via `.dockerignore`. Zscaler is only used locally when `USE_LOCAL_ZSCALER_CERT=true`. HF deployments will not load Zscaler certs.
86
 
87
+ ## Remote test
88
+
89
+ ```bash
90
+ test_scripts/test_remote_api.sh https://dromerosm-ddgs.hf.space <api_bearer_token>
91
+ ```
92
+
93
+ ## Postman
94
+
95
+ Import `postman_collection.json`. The Authorization header has an empty Bearer token by default.
96
+
97
  ## Environment variables
98
 
99
  - `DDGS_REGION`
postman_collection.json ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ {
2
+ "info": {
3
+ "name": "DDGS Search API",
4
+ "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
5
+ },
6
+ "item": [
7
+ {
8
+ "name": "Search",
9
+ "request": {
10
+ "method": "POST",
11
+ "header": [
12
+ {
13
+ "key": "Authorization",
14
+ "value": "Bearer ",
15
+ "type": "text"
16
+ },
17
+ {
18
+ "key": "Content-Type",
19
+ "value": "application/json",
20
+ "type": "text"
21
+ }
22
+ ],
23
+ "body": {
24
+ "mode": "raw",
25
+ "raw": "{\n \"query\": \"openai\",\n \"max_results\": 1,\n \"region\": \"us-en\",\n \"safesearch\": \"moderate\",\n \"timelimit\": \"m\",\n \"backend\": \"auto\",\n \"timeout\": 30,\n \"verify\": true\n}",
26
+ "options": {
27
+ "raw": {
28
+ "language": "json"
29
+ }
30
+ }
31
+ },
32
+ "url": {
33
+ "raw": "{{base_url}}/search",
34
+ "host": [
35
+ "{{base_url}}"
36
+ ],
37
+ "path": [
38
+ "search"
39
+ ]
40
+ }
41
+ }
42
+ }
43
+ ],
44
+ "variable": [
45
+ {
46
+ "key": "base_url",
47
+ "value": "https://dromerosm-ddgs.hf.space"
48
+ }
49
+ ]
50
+ }
test_scripts/test_remote_api.sh ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+
4
+ if [ $# -lt 2 ]; then
5
+ echo "Usage: $0 <base_url> <api_bearer_token>" >&2
6
+ echo "Example: $0 https://dromerosm-ddgs.hf.space <token>" >&2
7
+ exit 1
8
+ fi
9
+
10
+ BASE_URL="$1"
11
+ TOKEN="$2"
12
+
13
+ curl -s -X POST "$BASE_URL/search" \
14
+ -H "Authorization: Bearer $TOKEN" \
15
+ -H "Content-Type: application/json" \
16
+ -d '{"query":"openai","max_results":1,"region":"us-en","safesearch":"moderate","timelimit":"m","backend":"auto","timeout":30,"verify":true}' \
17
+ | python -c 'import json,sys; payload=json.load(sys.stdin); print("OK", payload.get("count"))'