File tree Expand file tree Collapse file tree 1 file changed +10
-14
lines changed
pkg/workloads/cortex/serve Expand file tree Collapse file tree 1 file changed +10
-14
lines changed Original file line number Diff line number Diff line change 25
25
26
26
from fastapi import Body , FastAPI
27
27
from fastapi .exceptions import RequestValidationError
28
+ from fastapi .middleware .cors import CORSMiddleware
28
29
from starlette .requests import Request
29
30
from starlette .responses import Response
30
31
from starlette .background import BackgroundTasks
31
32
from starlette .exceptions import HTTPException as StarletteHTTPException
32
- from starlette .applications import Starlette
33
- from starlette .middleware import Middleware
34
- from starlette .middleware .cors import CORSMiddleware
35
33
36
34
from cortex import consts
37
35
from cortex .lib import util
57
55
ThreadPoolExecutor (max_workers = int (os .environ ["CORTEX_THREADS_PER_WORKER" ]))
58
56
)
59
57
60
- middleware = [
61
- Middleware (
62
- CORSMiddleware ,
63
- allow_origins = ["*" ],
64
- allow_credentials = True ,
65
- allow_methods = ["*" ],
66
- allow_headers = ["*" ],
67
- )
68
- ]
69
-
70
- app = FastAPI (middleware = middleware )
58
+ app = FastAPI ()
59
+
60
+ app .add_middleware (
61
+ CORSMiddleware ,
62
+ allow_origins = ["*" ],
63
+ allow_credentials = True ,
64
+ allow_methods = ["*" ],
65
+ allow_headers = ["*" ],
66
+ )
71
67
72
68
local_cache = {"api" : None , "predictor_impl" : None , "client" : None , "class_set" : set ()}
73
69
You can’t perform that action at this time.
0 commit comments