Skip to content

Commit c948ef0

Browse files
committed
update
1 parent 055c6aa commit c948ef0

File tree

4 files changed

+21
-15
lines changed

4 files changed

+21
-15
lines changed
-211 Bytes
Binary file not shown.

Backend/texttoAIvideo.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,17 @@
1+
from fastapi import APIRouter
2+
from starlette.middleware.cors import CORSMiddleware
13

2-
from fastapi import FastAPI, APIRouter
3-
from fastapi.middleware.cors import CORSMiddleware
44

5-
app = FastAPI()
65
router = APIRouter()
76

7+
8+
89
@router.get('/api6')
910
async def get_text_from_file():
1011
with open('input.txt', 'r') as file:
1112
file_text = file.read(200)
1213
return file_text
1314

14-
# Register the router with the main FastAPI app
15-
app.include_router(router)
16-
17-
# Configure CORS
18-
app.add_middleware(
19-
CORSMiddleware,
20-
allow_origins=["http://localhost:3000"], # Replace with your frontend URL
21-
allow_credentials=True,
22-
allow_methods=["GET"],
23-
allow_headers=["*"],
24-
)
15+
16+
2517

__pycache__/main.cpython-310.pyc

256 Bytes
Binary file not shown.

main.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import uvicorn
22
from fastapi import FastAPI
3+
from fastapi.middleware.cors import CORSMiddleware
34

45
#from Backend.pyqsorter import router as api1_router
56
#from Backend.summariser import router_summariser as summariser
@@ -8,9 +9,22 @@
89
from Backend.texttoAIvideo import router as api6_router
910
# import other API routers as needed
1011

11-
app = FastAPI()
12+
origins = [
13+
"http://localhost:3000",
14+
"https://localhost:5000",
15+
]
16+
1217

18+
app = FastAPI()
1319

20+
# Configure CORS
21+
app.add_middleware(
22+
CORSMiddleware,
23+
allow_origins=origins, # Replace with your frontend URL
24+
allow_credentials=True,
25+
allow_methods=["*"],
26+
allow_headers=["*"],
27+
)
1428

1529
# Mount the API routerss
1630
#app.include_router(api1_router)

0 commit comments

Comments
 (0)