tuan243 commited on
Commit
cc84005
·
verified ·
1 Parent(s): f869e06

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -19
app.py CHANGED
@@ -5,27 +5,20 @@ import shutil
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")
 
5
  import uvicorn
6
  import os
7
  from funasr import AutoModel
8
+ from starlette.middleware import Middleware
9
+ from starlette.middleware.cors import CORSMiddleware
10
 
11
+ app = FastAPI(
12
+ middleware=[
13
+ Middleware(
14
+ CORSMiddleware,
15
+ allow_origins=["*"], # Cho phép tất cả các origin
16
+ allow_credentials=True,
17
+ allow_methods=["*"], # Cho phép tất cả các phương thức
18
+ allow_headers=["*"], # Cho phép tất cả các header
19
+ )
20
+ ]
 
 
21
  )
 
 
 
 
 
 
22
  # Tạo thư mục temp nếu chưa có
23
  if not os.path.exists("temp"):
24
  os.makedirs("temp")