Spaces:
Sleeping
Sleeping
| <html lang="en"> | |
| <head> | |
| <meta charset="UTF-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
| <title>API Documentation - PDF Layout Extractor</title> | |
| <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet"> | |
| <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css"> | |
| <style> | |
| .method-badge { | |
| display: inline-block; | |
| padding: 0.25em 0.6em; | |
| font-size: 0.75em; | |
| font-weight: 700; | |
| border-radius: 0.25rem; | |
| margin-right: 0.5rem; | |
| } | |
| .method-get { background-color: #28a745; color: white; } | |
| .method-post { background-color: #007bff; color: white; } | |
| .method-delete { background-color: #dc3545; color: white; } | |
| code { | |
| background-color: #f8f9fa; | |
| padding: 0.2em 0.4em; | |
| border-radius: 0.25rem; | |
| font-size: 0.9em; | |
| } | |
| .endpoint-card { | |
| margin-bottom: 1rem; | |
| transition: transform 0.2s; | |
| } | |
| .endpoint-card:hover { | |
| transform: translateY(-2px); | |
| box-shadow: 0 4px 8px rgba(0,0,0,0.1); | |
| } | |
| pre { | |
| margin: 0; | |
| } | |
| </style> | |
| </head> | |
| <body> | |
| <nav class="navbar navbar-expand-lg navbar-dark bg-primary"> | |
| <div class="container-fluid"> | |
| <a class="navbar-brand" href="/"> | |
| <i class="fas fa-file-pdf me-2"></i> | |
| PDF Layout Extractor - API Docs | |
| </a> | |
| <div> | |
| <a href="/" class="btn btn-light"> | |
| <i class="fas fa-arrow-left me-1"></i>Back to App | |
| </a> | |
| </div> | |
| </div> | |
| </nav> | |
| <div class="container mt-4 mb-5"> | |
| <h1 class="mb-4"><i class="fas fa-book me-2"></i>API Documentation</h1> | |
| <div class="alert alert-info"> | |
| <strong><i class="fas fa-info-circle me-2"></i>Base URL:</strong> <code>{{ base_url }}</code> | |
| </div> | |
| <div class="row"> | |
| <div class="col-12"> | |
| {% for route in routes %} | |
| <div class="card endpoint-card shadow-sm"> | |
| <div class="card-body"> | |
| <h5 class="card-title"> | |
| {% for method in route.methods.split(',') %} | |
| <span class="method-badge method-{{ method.lower() }}">{{ method }}</span> | |
| {% endfor %} | |
| <code>{{ route.endpoint }}</code> | |
| </h5> | |
| <p class="card-text text-muted">{{ route.description }}</p> | |
| <div class="mt-2"> | |
| <strong>Example Request:</strong> | |
| <pre class="bg-light p-2 rounded mt-2"><code>{% set method = route.methods.split(',')[0] %}{{ method }} {{ base_url }}{{ route.endpoint }}</code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| {% endfor %} | |
| </div> | |
| </div> | |
| <div class="mt-5"> | |
| <h2><i class="fas fa-code me-2"></i>Quick Examples</h2> | |
| <div class="card shadow-sm"> | |
| <div class="card-body"> | |
| <h5>Python Example</h5> | |
| <pre class="bg-light p-3 rounded"><code>import requests | |
| import time | |
| # Get device info | |
| response = requests.get('{{ base_url }}/api/device-info') | |
| print(response.json()) | |
| # Upload a PDF | |
| files = {'files[]': open('document.pdf', 'rb')} | |
| data = {'extraction_mode': 'both'} # or 'images' or 'markdown' | |
| response = requests.post('{{ base_url }}/api/upload', files=files, data=data) | |
| task_id = response.json()['task_id'] | |
| # Check progress | |
| while True: | |
| progress = requests.get(f'{{ base_url }}/api/progress/{task_id}').json() | |
| print(f"Progress: {progress['progress']}% - {progress['message']}") | |
| if progress['status'] == 'completed': | |
| break | |
| time.sleep(0.5) | |
| # Get results | |
| results = progress['results'] | |
| for result in results: | |
| print(f"Processed: {result['filename']}") | |
| print(f" Figures: {result['figures_count']}") | |
| print(f" Tables: {result['tables_count']}")</code></pre> | |
| </div> | |
| </div> | |
| <div class="card shadow-sm mt-3"> | |
| <div class="card-body"> | |
| <h5>cURL Example</h5> | |
| <pre class="bg-light p-3 rounded"><code># Get device info | |
| curl {{ base_url }}/api/device-info | |
| # Upload a PDF | |
| curl -X POST {{ base_url }}/api/upload \ | |
| -F "files[]=@document.pdf" \ | |
| -F "extraction_mode=both" | |
| # Check progress (replace TASK_ID) | |
| curl {{ base_url }}/api/progress/TASK_ID | |
| # List processed PDFs | |
| curl {{ base_url }}/api/pdf-list</code></pre> | |
| </div> | |
| </div> | |
| </div> | |
| <div class="mt-5"> | |
| <h2><i class="fas fa-question-circle me-2"></i>API Endpoints Overview</h2> | |
| <div class="table-responsive"> | |
| <table class="table table-striped"> | |
| <thead> | |
| <tr> | |
| <th>Method</th> | |
| <th>Endpoint</th> | |
| <th>Description</th> | |
| </tr> | |
| </thead> | |
| <tbody> | |
| {% for route in routes %} | |
| <tr> | |
| <td> | |
| {% for method in route.methods.split(',') %} | |
| <span class="method-badge method-{{ method.lower() }}">{{ method }}</span> | |
| {% endfor %} | |
| </td> | |
| <td><code>{{ route.endpoint }}</code></td> | |
| <td>{{ route.description }}</td> | |
| </tr> | |
| {% endfor %} | |
| </tbody> | |
| </table> | |
| </div> | |
| </div> | |
| </div> | |
| <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js"></script> | |
| </body> | |
| </html> | |