hamza82 commited on
Commit
a14158b
·
verified ·
1 Parent(s): 7394738

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -0
app.py CHANGED
@@ -99,6 +99,7 @@ from fastapi.staticfiles import StaticFiles
99
  from fastapi.responses import FileResponse, JSONResponse
100
  import os
101
  import logging
 
102
  from openai import AsyncOpenAI
103
  # Import your custom modules
104
  from chainlit.auth import create_jwt
@@ -114,6 +115,14 @@ logger = logging.getLogger(__name__) # Use __name__ to get the root logger
114
 
115
  app = FastAPI()
116
 
 
 
 
 
 
 
 
 
117
  client = AsyncOpenAI(api_key=os.environ["OPENAI_API_KEY"])
118
 
119
  settings = {
 
99
  from fastapi.responses import FileResponse, JSONResponse
100
  import os
101
  import logging
102
+ from fastapi.middleware.cors import CORSMiddleware
103
  from openai import AsyncOpenAI
104
  # Import your custom modules
105
  from chainlit.auth import create_jwt
 
115
 
116
  app = FastAPI()
117
 
118
+ CORS middleware setup
119
+ app.add_middleware(
120
+ CORSMiddleware,
121
+ allow_origins=["*"], # Specify domains or use ["*"] for open access
122
+ allow_credentials=True,
123
+ allow_methods=["*"], # Specify methods or use ["*"] for all methods
124
+ allow_headers=["*"], # Specify headers or use ["*"] for all headers
125
+ )
126
  client = AsyncOpenAI(api_key=os.environ["OPENAI_API_KEY"])
127
 
128
  settings = {