File tree Expand file tree Collapse file tree 1 file changed +14
-10
lines changed
pkg/workloads/cortex/serve Expand file tree Collapse file tree 1 file changed +14
-10
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
29
28
from starlette .requests import Request
30
29
from starlette .responses import Response
31
30
from starlette .background import BackgroundTasks
32
31
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
33
35
34
36
from cortex import consts
35
37
from cortex .lib import util
55
57
ThreadPoolExecutor (max_workers = int (os .environ ["CORTEX_THREADS_PER_WORKER" ]))
56
58
)
57
59
58
- app = FastAPI ()
59
-
60
- app .add_middleware (
61
- CORSMiddleware ,
62
- allow_origins = ["*" ],
63
- allow_credentials = True ,
64
- allow_methods = ["*" ],
65
- allow_headers = ["*" ],
66
- )
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 )
67
71
68
72
local_cache = {"api" : None , "predictor_impl" : None , "client" : None , "class_set" : set ()}
69
73
You can’t perform that action at this time.
0 commit comments