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

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +34 -2
app.py CHANGED
@@ -1,12 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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(...)):
 
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}
21
  from fastapi import FastAPI, UploadFile, File
22
+ from fastapi.responses import HTMLResponse
23
  import shutil
24
  from inference import process_document
25
 
26
  app = FastAPI()
27
 
28
+ @app.get("/", response_class=HTMLResponse)
29
  def root():
30
+ return """
31
+ <html>
32
+ <head>
33
+ <title>Qwen Extraction API</title>
34
+ </head>
35
+ <body>
36
+ <h2>✅ Qwen Extraction API Running</h2>
37
+ <p>Use POST /extract to upload file</p>
38
+ <a href="/docs">Go to API Docs</a>
39
+ </body>
40
+ </html>
41
+ """
42
 
43
  @app.post("/extract")
44
  async def extract(file: UploadFile = File(...)):