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 2525
2626from fastapi import Body , FastAPI
2727from fastapi .exceptions import RequestValidationError
28- from fastapi .middleware .cors import CORSMiddleware
2928from starlette .requests import Request
3029from starlette .responses import Response
3130from starlette .background import BackgroundTasks
3231from 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
3335
3436from cortex import consts
3537from cortex .lib import util
5557 ThreadPoolExecutor (max_workers = int (os .environ ["CORTEX_THREADS_PER_WORKER" ]))
5658)
5759
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 )
6771
6872local_cache = {"api" : None , "predictor_impl" : None , "client" : None , "class_set" : set ()}
6973
You can’t perform that action at this time.
0 commit comments