credent007 commited on
Commit
92b81d7
·
verified ·
1 Parent(s): 0601688

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from fastapi import FastAPI, UploadFile, File
2
+ import shutil
3
+ from inference import process_document
4
+
5
+ app = FastAPI()
6
+
7
+ @app.get("/")
8
+ def root():
9
+ return {"status": "API running"}
10
+
11
+ @app.post("/extract")
12
+ async def extract(file: UploadFile = File(...)):
13
+ file_path = f"/tmp/{file.filename}"
14
+
15
+ with open(file_path, "wb") as buffer:
16
+ shutil.copyfileobj(file.file, buffer)
17
+
18
+ result = process_document(file_path)
19
+
20
+ return {"result": result}