LongK171 commited on
Commit
ef9710d
·
1 Parent(s): dbe2c62

update middleware

Browse files
Files changed (2) hide show
  1. Demo/Assets/script.js +2 -1
  2. app.py +9 -0
Demo/Assets/script.js CHANGED
@@ -123,7 +123,8 @@ document.addEventListener("DOMContentLoaded", () => {
123
  formData.append("file", file);
124
 
125
  try {
126
- const response = await fetch("http://127.0.0.1:8000/process_pdf", {
 
127
  method: "POST",
128
  body: formData
129
  });
 
123
  formData.append("file", file);
124
 
125
  try {
126
+ // const response = await fetch("http://127.0.0.1:8000/process_pdf", {
127
+ const response = await fetch("https://orias171-doc-ai-api.hf.space/process_pdf", {
128
  method: "POST",
129
  body: formData
130
  });
app.py CHANGED
@@ -12,6 +12,7 @@ import time
12
  from typing import Optional
13
 
14
  from fastapi import FastAPI, UploadFile, File, HTTPException, Depends, Header
 
15
  from fastapi.responses import JSONResponse
16
  from pydantic import BaseModel
17
 
@@ -49,6 +50,14 @@ app = FastAPI(
49
  description="API xử lý PDF: trích xuất, tóm tắt, tìm kiếm, phân loại.",
50
  )
51
 
 
 
 
 
 
 
 
 
52
  # -------------------------
53
  # 🩺 /health
54
  # -------------------------
 
12
  from typing import Optional
13
 
14
  from fastapi import FastAPI, UploadFile, File, HTTPException, Depends, Header
15
+ from fastapi.middleware.cors import CORSMiddleware
16
  from fastapi.responses import JSONResponse
17
  from pydantic import BaseModel
18
 
 
50
  description="API xử lý PDF: trích xuất, tóm tắt, tìm kiếm, phân loại.",
51
  )
52
 
53
+ app.add_middleware(
54
+ CORSMiddleware,
55
+ allow_origins=["*"],
56
+ allow_credentials=True,
57
+ allow_methods=["*"],
58
+ allow_headers=["*"],
59
+ )
60
+
61
  # -------------------------
62
  # 🩺 /health
63
  # -------------------------