Gregniuki commited on
Commit
625461f
·
1 Parent(s): f06079d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -8
app.py CHANGED
@@ -1,12 +1,19 @@
1
- from fastapi import FastAPI
2
- from fastapi.middleware.cors import CORSMiddleware
3
- from app.routes import auth, main # Import your route-related modules
 
 
4
 
5
  app = FastAPI()
6
 
7
- # CORS configuration, error handlers, and other global settings
8
- app.add_middleware(CORSMiddleware, allow_origins=["*"])
 
 
 
9
 
10
- # Include route-related modules
11
- app.include_router(auth.router)
12
- app.include_router(main.router)
 
 
 
1
+ # main.py
2
+
3
+ from fastapi import FastAPI, Depends, HTTPException
4
+ from app.routes import auth, tts
5
+ from app.auth import verify_token # Import a function for verifying tokens
6
 
7
  app = FastAPI()
8
 
9
+ # Include the authentication router with the prefix '/auth'
10
+ app.include_router(auth.router, prefix="/auth")
11
+
12
+ # Include the TTS router with the prefix '/tts'
13
+ app.include_router(tts.router, prefix="/tts")
14
 
15
+ # Dependency for verifying the user's token
16
+ def get_current_user(token: str = Depends(verify_token)):
17
+ if not token:
18
+ raise HTTPException(status_code=401, detail="Token not valid")
19
+ return token