Kadigas commited on
Commit
5f18626
·
1 Parent(s): 9da767a

feat: cors middleware

Browse files
Files changed (2) hide show
  1. __pycache__/main.cpython-310.pyc +0 -0
  2. main.py +10 -1
__pycache__/main.cpython-310.pyc CHANGED
Binary files a/__pycache__/main.cpython-310.pyc and b/__pycache__/main.cpython-310.pyc differ
 
main.py CHANGED
@@ -4,12 +4,21 @@
4
  from fastapi import FastAPI, Form, Depends, Request
5
  from fastapi.encoders import jsonable_encoder
6
  from fastapi.responses import JSONResponse
 
7
  from pydantic import BaseModel
8
  import pickle
9
- import json
10
 
11
  app = FastAPI()
12
 
 
 
 
 
 
 
 
 
 
13
  model_file = open('insurance_model.pkl', 'rb')
14
  model = pickle.load(model_file, encoding='bytes')
15
 
 
4
  from fastapi import FastAPI, Form, Depends, Request
5
  from fastapi.encoders import jsonable_encoder
6
  from fastapi.responses import JSONResponse
7
+ from fastapi.middleware.cors import CORSMiddleware
8
  from pydantic import BaseModel
9
  import pickle
 
10
 
11
  app = FastAPI()
12
 
13
+ # Add CORS middleware
14
+ app.add_middleware(
15
+ CORSMiddleware,
16
+ allow_origins=["*"], # Replace with the list of allowed origins for production
17
+ allow_credentials=True,
18
+ allow_methods=["*"],
19
+ allow_headers=["*"],
20
+ )
21
+
22
  model_file = open('insurance_model.pkl', 'rb')
23
  model = pickle.load(model_file, encoding='bytes')
24