File tree Expand file tree Collapse file tree 4 files changed +21
-15
lines changed Expand file tree Collapse file tree 4 files changed +21
-15
lines changed Original file line number Diff line number Diff line change
1
+ from fastapi import APIRouter
2
+ from starlette .middleware .cors import CORSMiddleware
1
3
2
- from fastapi import FastAPI , APIRouter
3
- from fastapi .middleware .cors import CORSMiddleware
4
4
5
- app = FastAPI ()
6
5
router = APIRouter ()
7
6
7
+
8
+
8
9
@router .get ('/api6' )
9
10
async def get_text_from_file ():
10
11
with open ('input.txt' , 'r' ) as file :
11
12
file_text = file .read (200 )
12
13
return file_text
13
14
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
+
25
17
Original file line number Diff line number Diff line change 1
1
import uvicorn
2
2
from fastapi import FastAPI
3
+ from fastapi .middleware .cors import CORSMiddleware
3
4
4
5
#from Backend.pyqsorter import router as api1_router
5
6
#from Backend.summariser import router_summariser as summariser
8
9
from Backend .texttoAIvideo import router as api6_router
9
10
# import other API routers as needed
10
11
11
- app = FastAPI ()
12
+ origins = [
13
+ "http://localhost:3000" ,
14
+ "https://localhost:5000" ,
15
+ ]
16
+
12
17
18
+ app = FastAPI ()
13
19
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
+ )
14
28
15
29
# Mount the API routerss
16
30
#app.include_router(api1_router)
You can’t perform that action at this time.
0 commit comments