saifisvibinn commited on
Commit
2226eb2
·
1 Parent(s): dbd5338

Fix API docs: ensure HTTPS, add /api/predict endpoint to README

Browse files
Files changed (3) hide show
  1. POSTMAN_TESTING_GUIDE.md +3 -0
  2. README.md +23 -2
  3. app.py +3 -0
POSTMAN_TESTING_GUIDE.md CHANGED
@@ -109,9 +109,12 @@ If you want to use `/api/upload` for async processing:
109
  ## Quick Test with cURL
110
 
111
  ```bash
 
112
  curl -X POST https://saifisvibin-volaris-pdf-tool.hf.space/api/predict \
113
  -F "file=@your_document.pdf"
114
  ```
115
 
 
 
116
  Replace `your_document.pdf` with your actual PDF file path.
117
 
 
109
  ## Quick Test with cURL
110
 
111
  ```bash
112
+ # Test with HTTPS (required for Hugging Face Spaces)
113
  curl -X POST https://saifisvibin-volaris-pdf-tool.hf.space/api/predict \
114
  -F "file=@your_document.pdf"
115
  ```
116
 
117
+ **Important:** Always use `https://` (not `http://`) when accessing Hugging Face Spaces. The platform automatically redirects HTTP to HTTPS, but you should use HTTPS directly.
118
+
119
  Replace `your_document.pdf` with your actual PDF file path.
120
 
README.md CHANGED
@@ -23,20 +23,41 @@ A powerful tool for extracting figures, tables, annotated layouts, and markdown
23
 
24
  ## API Endpoints
25
 
26
- - `POST /api/upload` - Upload PDFs for processing (returns `task_id`)
 
 
 
27
  - `GET /api/progress/<task_id>` - Get processing progress (0-100%)
28
  - `GET /api/pdf-list` - List all processed PDFs
29
  - `GET /api/pdf-details/<pdf_stem>` - Get details for a processed PDF
30
  - `GET /api/device-info` - Get GPU/CPU device information
 
31
  - `GET /output/<path>` - Download processed files (PDFs, images, markdown)
32
 
33
  ## Example API Usage
34
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
35
  ```python
36
  import requests
37
  import time
38
 
39
- # Upload a PDF
40
  files = {'files[]': open('document.pdf', 'rb')}
41
  data = {'extraction_mode': 'both'} # or 'images' or 'markdown'
42
  response = requests.post('https://saifisvibin-volaris-pdf-tool.hf.space/api/upload', files=files, data=data)
 
23
 
24
  ## API Endpoints
25
 
26
+ **Base URL:** `https://saifisvibin-volaris-pdf-tool.hf.space`
27
+
28
+ - `POST /api/predict` - **Recommended**: Synchronous PDF extraction (returns complete results immediately)
29
+ - `POST /api/upload` - Upload PDFs for async processing (returns `task_id`)
30
  - `GET /api/progress/<task_id>` - Get processing progress (0-100%)
31
  - `GET /api/pdf-list` - List all processed PDFs
32
  - `GET /api/pdf-details/<pdf_stem>` - Get details for a processed PDF
33
  - `GET /api/device-info` - Get GPU/CPU device information
34
+ - `GET /api/docs` - Interactive API documentation
35
  - `GET /output/<path>` - Download processed files (PDFs, images, markdown)
36
 
37
  ## Example API Usage
38
 
39
+ ### Simple Synchronous Extraction (Recommended)
40
+
41
+ ```python
42
+ import requests
43
+
44
+ # Upload and get results immediately
45
+ files = {'file': open('document.pdf', 'rb')}
46
+ response = requests.post('https://saifisvibin-volaris-pdf-tool.hf.space/api/predict', files=files)
47
+ result = response.json()
48
+
49
+ print(f"Text: {result['text']}")
50
+ print(f"Figures: {len(result['figures'])}")
51
+ print(f"Tables: {len(result['tables'])}")
52
+ ```
53
+
54
+ ### Async Processing with Progress
55
+
56
  ```python
57
  import requests
58
  import time
59
 
60
+ # Upload a PDF (async)
61
  files = {'files[]': open('document.pdf', 'rb')}
62
  data = {'extraction_mode': 'both'} # or 'images' or 'markdown'
63
  response = requests.post('https://saifisvibin-volaris-pdf-tool.hf.space/api/upload', files=files, data=data)
app.py CHANGED
@@ -85,7 +85,10 @@ def api_docs():
85
  'description': doc.strip() if doc else 'No description'
86
  })
87
 
 
88
  base_url = request.host_url.rstrip('/')
 
 
89
  return render_template('api_docs.html', routes=routes, base_url=base_url)
90
 
91
 
 
85
  'description': doc.strip() if doc else 'No description'
86
  })
87
 
88
+ # Force HTTPS for Hugging Face Spaces (always use HTTPS)
89
  base_url = request.host_url.rstrip('/')
90
+ if base_url.startswith('http://'):
91
+ base_url = base_url.replace('http://', 'https://')
92
  return render_template('api_docs.html', routes=routes, base_url=base_url)
93
 
94