mirror of
				https://github.com/ijaric/voice_assistant.git
				synced 2025-10-31 01:43:25 +00:00 
			
		
		
		
	Настройки через app
This commit is contained in:
		
							parent
							
								
									52b1c6b365
								
							
						
					
					
						commit
						ed9a93a04f
					
				|  | @ -4,7 +4,6 @@ import logging | |||
| import uvicorn | ||||
| 
 | ||||
| import lib.app.app as app_module | ||||
| import lib.app.settings as app_settings | ||||
| 
 | ||||
| logger = logging.getLogger(__name__) | ||||
| 
 | ||||
|  | @ -12,11 +11,11 @@ logger = logging.getLogger(__name__) | |||
| async def main(): | ||||
|     try: | ||||
|         app_instance = app_module.Application() | ||||
| 
 | ||||
|         app = app_instance.create_app() | ||||
|         settings = app_settings.get_settings() | ||||
|         settings = app_instance.settings | ||||
| 
 | ||||
|         logger.info("Starting FastAPI application") | ||||
| 
 | ||||
|         config = uvicorn.Config(app=app, host=settings.api.host, port=settings.api.port, lifespan="on", reload=True) | ||||
|         server = uvicorn.Server(config) | ||||
| 
 | ||||
|  |  | |||
|  | @ -3,15 +3,14 @@ from jose import JWTError, jwt | |||
| from pydantic import ValidationError | ||||
| 
 | ||||
| import lib.api.schemas as app_schemas | ||||
| import lib.app.settings as app_settings | ||||
| 
 | ||||
| settings = app_settings.get_settings() | ||||
| 
 | ||||
| 
 | ||||
| def get_token_data( | ||||
|     request: fastapi.Request, | ||||
|     authorization: fastapi.security.HTTPAuthorizationCredentials = fastapi.Security(fastapi.security.HTTPBearer()), | ||||
| ) -> app_schemas.entity.Token: | ||||
|     token = authorization.credentials | ||||
|     settings = request.app.state.settings | ||||
|     try: | ||||
|         secret_key = settings.jwt_secret_key | ||||
|         payload = jwt.decode(token, secret_key, algorithms=["HS256"]) | ||||
|  |  | |||
|  | @ -69,6 +69,8 @@ class Application: | |||
|         async def shutdown_event(): | ||||
|             self.logger.info("Shutting down server") | ||||
| 
 | ||||
|         app.state.settings = self.settings | ||||
| 
 | ||||
|         return app | ||||
| 
 | ||||
| 
 | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue
	
	Block a user