Spaces:
Build error
Build error
Upload main.py
Browse files
main.py
CHANGED
|
@@ -4,6 +4,7 @@ import uvicorn
|
|
| 4 |
|
| 5 |
from pydantic import BaseModel
|
| 6 |
from fastapi import FastAPI, File, UploadFile, HTTPException
|
|
|
|
| 7 |
|
| 8 |
from app.app import data_ingestion, handle_query, DATA_DIR
|
| 9 |
|
|
@@ -12,6 +13,14 @@ class Query(BaseModel):
|
|
| 12 |
|
| 13 |
app = FastAPI()
|
| 14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 15 |
@app.post("/upload")
|
| 16 |
async def upload_file(file: UploadFile = File(...)):
|
| 17 |
file_extension = os.path.splitext(file.filename)[1].lower()
|
|
|
|
| 4 |
|
| 5 |
from pydantic import BaseModel
|
| 6 |
from fastapi import FastAPI, File, UploadFile, HTTPException
|
| 7 |
+
from fastapi.middleware.cors import CORSMiddleware
|
| 8 |
|
| 9 |
from app.app import data_ingestion, handle_query, DATA_DIR
|
| 10 |
|
|
|
|
| 13 |
|
| 14 |
app = FastAPI()
|
| 15 |
|
| 16 |
+
app.add_middleware(
|
| 17 |
+
CORSMiddleware,
|
| 18 |
+
allow_origins=["*"], # Adjust this to your needs
|
| 19 |
+
allow_credentials=True,
|
| 20 |
+
allow_methods=["*"],
|
| 21 |
+
allow_headers=["*"],
|
| 22 |
+
)
|
| 23 |
+
|
| 24 |
@app.post("/upload")
|
| 25 |
async def upload_file(file: UploadFile = File(...)):
|
| 26 |
file_extension = os.path.splitext(file.filename)[1].lower()
|