Skip to content

Commit b4e7615

Browse files
committed
enable CORS
1 parent 237df05 commit b4e7615

File tree

6 files changed

+30
-4
lines changed

6 files changed

+30
-4
lines changed
2 Bytes
Binary file not shown.
700 Bytes
Binary file not shown.

Backend/texttoAIvideo.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
from fastapi import APIRouter
2+
from fastapi.middleware.cors import CORSMiddleware
3+
4+
router = APIRouter()
5+
6+
@router.get('/api6')
7+
async def get_text_from_file():
8+
9+
with open('input.txt', 'r') as file:
10+
file_text = file.read(200)
11+
return file_text
12+
13+
# Configure CORS
14+
origins = [
15+
"http://localhost:3000", # Replace with your frontend URL
16+
# Add more allowed origins if needed
17+
]
18+
19+
router.add_middleware(
20+
CORSMiddleware,
21+
allow_origins=origins,
22+
allow_credentials=True,
23+
allow_methods=["GET", "POST", "PUT", "DELETE"],
24+
allow_headers=["*"],
25+
)

__pycache__/main.cpython-310.pyc

55 Bytes
Binary file not shown.

input.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
hello

main.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@
33

44
#from Backend.pyqsorter import router as api1_router
55
#from Backend.summariser import router_summariser as summariser
6-
#from Backend.Notes_Analyser import router as api4_router
7-
from Backend.speech_text import router as api5_router
8-
6+
from Backend.Notes_Analyser import router as api4_router
7+
#from Backend.speech_text import router as api5_router
8+
from Backend.texttoAIvideo import router as api6_router
99
# import other API routers as needed
1010

1111
app = FastAPI()
@@ -16,7 +16,7 @@
1616
#app.include_router(api1_router)
1717
#app.include_router(summariser)
1818
#app.include_router(api4_router)
19-
app.include_router(api5_router)
19+
app.include_router(api6_router)
2020

2121

2222
# include other API routers as needed

0 commit comments

Comments
 (0)