tuan243 commited on
Commit
0dcf377
·
verified ·
1 Parent(s): 837b785

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -1
app.py CHANGED
@@ -5,10 +5,27 @@ import shutil
5
  import uvicorn
6
  import os
7
  from funasr import AutoModel
 
8
 
9
- # Khởi tạo FastAPI
10
  app = FastAPI()
11
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  # Tạo thư mục temp nếu chưa có
13
  if not os.path.exists("temp"):
14
  os.makedirs("temp")
 
5
  import uvicorn
6
  import os
7
  from funasr import AutoModel
8
+ from fastapi.middleware.cors import CORSMiddleware
9
 
 
10
  app = FastAPI()
11
 
12
+ origins = [
13
+ "*", #tất cả các trang đều có thể truy cập vào api
14
+ ]
15
+
16
+ app.add_middleware(
17
+ CORSMiddleware,
18
+ allow_origins=origins,
19
+ allow_credentials=True,
20
+ allow_methods=["*"], # Cho phép tất cả các phương thức HTTP
21
+ allow_headers=["*"], # Cho phép tất cả các header
22
+ )
23
+
24
+ @app.post("/detect-noise/")
25
+ async def detect_noise_api():
26
+ return {"message": "Hello from POST endpoint"}
27
+
28
+
29
  # Tạo thư mục temp nếu chưa có
30
  if not os.path.exists("temp"):
31
  os.makedirs("temp")