Create and configure the aiohttp application
(self)
| 106 | return ssl_context |
| 107 | |
| 108 | async def create_app(self) -> web.Application: |
| 109 | """Create and configure the aiohttp application""" |
| 110 | # Create application with proper settings |
| 111 | app = web.Application( |
| 112 | client_max_size=1024**2 * 10, # 10MB max request size |
| 113 | ) |
| 114 | |
| 115 | # Store config in app for access in handlers |
| 116 | app['config'] = self.config |
| 117 | |
| 118 | # Setup middleware |
| 119 | from .middleware import setup_middleware |
| 120 | setup_middleware(app) |
| 121 | |
| 122 | # Setup routes |
| 123 | from .routes import setup_routes |
| 124 | setup_routes(app) |
| 125 | |
| 126 | # Setup startup and cleanup handlers |
| 127 | app.on_startup.append(self._on_startup) |
| 128 | app.on_cleanup.append(self._on_cleanup) |
| 129 | app.on_shutdown.append(self._on_shutdown) |
| 130 | |
| 131 | # Setup client session for outgoing requests |
| 132 | app['client_session'] = None |
| 133 | |
| 134 | return app |
| 135 | |
| 136 | async def _on_startup(self, app: web.Application): |
| 137 | """Initialize resources on startup""" |