Spaces:
Paused
Paused
| # from fastapi import FastAPI, UploadFile, File | |
| # import shutil | |
| # from inference import process_document | |
| # app = FastAPI() | |
| # @app.get("/") | |
| # def root(): | |
| # return {"status": "API running"} | |
| # @app.post("/extract") | |
| # async def extract(file: UploadFile = File(...)): | |
| # file_path = f"/tmp/{file.filename}" | |
| # with open(file_path, "wb") as buffer: | |
| # shutil.copyfileobj(file.file, buffer) | |
| # result = process_document(file_path) | |
| # return {"result": result} | |
| from fastapi import FastAPI, UploadFile, File | |
| from fastapi.responses import HTMLResponse | |
| import shutil | |
| from inference import process_document | |
| from json_handling import process_whole_doc | |
| app = FastAPI() | |
| def root(): | |
| return """ | |
| <html> | |
| <head> | |
| <title>Qwen Extraction API</title> | |
| </head> | |
| <body> | |
| <h2>✅ Qwen Extraction API Running</h2> | |
| <p>Use POST /extract to upload file</p> | |
| <a href="/docs">Go to API Docs</a> | |
| </body> | |
| </html> | |
| """ | |
| async def extract(file: UploadFile = File(...)): | |
| file_path = f"/tmp/{file.filename}" | |
| with open(file_path, "wb") as buffer: | |
| shutil.copyfileobj(file.file, buffer) | |
| # result = process_document(file_path) | |
| result = process_whole_doc(file_path) | |
| return {"result": result} |