update FastAPI middleware configuration and change server command to use Uvicorn
This commit is contained in:
17
main.py
17
main.py
@@ -12,9 +12,6 @@ from constants import API_ROOT
|
|||||||
from external.kafka import consume_messages
|
from external.kafka import consume_messages
|
||||||
from external.kafka.producer import init_producer, get_producer
|
from external.kafka.producer import init_producer, get_producer
|
||||||
|
|
||||||
origins = [
|
|
||||||
'http://localhost:5173'
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
@asynccontextmanager
|
@asynccontextmanager
|
||||||
@@ -38,13 +35,13 @@ async def lifespan(app: FastAPI):
|
|||||||
|
|
||||||
app = FastAPI(lifespan=lifespan, separate_input_output_schemas=False, root_path='/api')
|
app = FastAPI(lifespan=lifespan, separate_input_output_schemas=False, root_path='/api')
|
||||||
|
|
||||||
app.add_middleware(
|
# app.add_middleware(
|
||||||
CORSMiddleware,
|
# CORSMiddleware,
|
||||||
allow_origins=origins,
|
# allow_origins=origins,
|
||||||
allow_credentials=True,
|
# allow_credentials=True,
|
||||||
allow_methods=["*"],
|
# allow_methods=["*"],
|
||||||
allow_headers=["*"],
|
# allow_headers=["*"],
|
||||||
)
|
# )
|
||||||
|
|
||||||
routers_list = [
|
routers_list = [
|
||||||
routers.attribute_router,
|
routers.attribute_router,
|
||||||
|
|||||||
2
start_fastapi.sh
Normal file → Executable file
2
start_fastapi.sh
Normal file → Executable file
@@ -1 +1 @@
|
|||||||
gunicorn main:app -w 4
|
uvicorn main:app --host 0.0.0.0 --port 8000 --workers 4
|
||||||
Reference in New Issue
Block a user