mirror of
				https://github.com/ijaric/voice_assistant.git
				synced 2025-10-30 23:53:25 +00:00 
			
		
		
		
	fix: return original app.py
This commit is contained in:
		
							parent
							
								
									a6fac4a95b
								
							
						
					
					
						commit
						47d8745928
					
				|  | @ -1,27 +1,19 @@ | ||||||
| import logging | import logging | ||||||
| 
 | 
 | ||||||
| import fastapi | import fastapi | ||||||
| import sqlalchemy |  | ||||||
| import sqlalchemy.ext.asyncio as sa_asyncio |  | ||||||
| 
 | 
 | ||||||
| import lib.app.settings as app_settings | import lib.app.settings as app_settings | ||||||
| import lib.clients as clients |  | ||||||
| 
 |  | ||||||
| # import sqlalchemy.ext.asyncio as sa_asyncio |  | ||||||
| 
 |  | ||||||
| 
 | 
 | ||||||
| logger = logging.getLogger(__name__) | logger = logging.getLogger(__name__) | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| class Application: | class Application: | ||||||
|     def __init__(self) -> None: |     def __init__(self) -> None: | ||||||
|         self.settings = app_settings.settings |         self.settings = app_settings | ||||||
|         self.logger = logging.getLogger(__name__) |         self.logger = logging.getLogger(__name__) | ||||||
|         self.producer = None |         self.producer = None | ||||||
| 
 | 
 | ||||||
|     async def create_app(self) -> fastapi.FastAPI: |     def create_app(self) -> fastapi.FastAPI: | ||||||
|         postgres_client = clients.get_async_session(self.settings.postgres) |  | ||||||
| 
 |  | ||||||
|         app = fastapi.FastAPI( |         app = fastapi.FastAPI( | ||||||
|             title="FastAPI", |             title="FastAPI", | ||||||
|             version="0.1.0", |             version="0.1.0", | ||||||
|  | @ -30,26 +22,15 @@ class Application: | ||||||
|             default_response_class=fastapi.responses.ORJSONResponse, |             default_response_class=fastapi.responses.ORJSONResponse, | ||||||
|         ) |         ) | ||||||
| 
 | 
 | ||||||
|         router = fastapi.APIRouter() |  | ||||||
| 
 |  | ||||||
|         @router.get("/health") |  | ||||||
|         async def health(get_async_session: sa_asyncio.async_sessionmaker[sa_asyncio.AsyncSession]): |  | ||||||
|             async with get_async_session.begin() as session: |  | ||||||
|                 statement = sqlalchemy.text("SELECT 1") |  | ||||||
|                 results = await session.execute(statement) |  | ||||||
|                 print(results.unique().scalar_one_or_none()) |  | ||||||
|             return {"status": "ok"} |  | ||||||
| 
 |  | ||||||
|         app.include_router(router) |  | ||||||
|         # app.include_router(api_handlers.user_router, prefix="/api/v1/users", tags=["users"]) |         # app.include_router(api_handlers.user_router, prefix="/api/v1/users", tags=["users"]) | ||||||
|         # app.include_router(api_handlers.movie_router, prefix="/api/v1/movies", tags=["movies"]) |         # app.include_router(api_handlers.movie_router, prefix="/api/v1/movies", tags=["movies"]) | ||||||
| 
 | 
 | ||||||
|         @app.on_event("startup") |         @app.on_event("startup") | ||||||
|         async def startup_event():  # noqa: ANN202 |         async def startup_event(): | ||||||
|             self.logger.info("Starting server") |             self.logger.info("Starting server") | ||||||
| 
 | 
 | ||||||
|         @app.on_event("shutdown") |         @app.on_event("shutdown") | ||||||
|         async def shutdown_event():  # noqa: ANN202 |         async def shutdown_event(): | ||||||
|             self.logger.info("Shutting down server") |             self.logger.info("Shutting down server") | ||||||
| 
 | 
 | ||||||
|         return app |         return app | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue
	
	Block a user