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 2525
2626from fastapi import Body , FastAPI
2727from fastapi .exceptions import RequestValidationError
28+ from fastapi .middleware .cors import CORSMiddleware
2829from starlette .requests import Request
2930from starlette .responses import Response
3031from starlette .background import BackgroundTasks
3132from 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
3533
3634from cortex import consts
3735from cortex .lib import util
5755 ThreadPoolExecutor (max_workers = int (os .environ ["CORTEX_THREADS_PER_WORKER" ]))
5856)
5957
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+ )
7167
7268local_cache = {"api" : None , "predictor_impl" : None , "client" : None , "class_set" : set ()}
7369
You can’t perform that action at this time.
0 commit comments