Flask-Injector
Adds Injector, a Dependency Injection framework, support to Flask.
What it is and what it does
Flask-Injector bridges the Injector dependency-injection framework into Flask applications. Instead of using Flask's global objects (like the global request context or extension singletons), you define dependencies in Injector modules and have them automatically injected into views, request handlers, template processors, and other Flask components. This eliminates the need for global state, making applications easier to test and reason about.
The package works by wrapping Flask's initialization and hooking into its request lifecycle. It binds Flask's core objects (the app, config, and request) into the Injector container at appropriate scopes (singleton for app and config, request-scoped for the current request), then resolves function parameters by type annotation. It integrates with Flask-RESTful, Flask-RestPlus, and Flask-RESTX resource constructors, and supports custom scopes for advanced use cases.
Use it for:
- Build testable Flask applications by injecting mock dependencies instead of relying on global Flask objects during unit tests.
- Manage database connections, caches, or service clients as request-scoped or singleton dependencies without global initialization.
- Integrate Flask extensions through Injector modules instead of the typical global pattern.
- Implement class-based views with constructor injection to avoid accessing globals in __init__ methods.
- Decouple Flask route handlers from concrete implementations by injecting interfaces or abstract services.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Integrates dependency injection into Flask applications using the Injector framework, allowing you to inject dependencies into views, handlers, and other Flask components without relying on global objects.
Yes, with conditions. Flask-Injector is stable and well-suited for new Flask projects that prioritize testability and clean dependency management. However, the dormant maintenance status (last release 2023-07-27) means you should verify compatibility with your target Flask and Injector versions before committing. If your project requires active upstream support or frequent dependency updates, consider whether the risk of stale maintenance is acceptable. For established projects with fixed dependencies, it remains a solid choice.
Install
flask-injector on PyPI
pip
pip install flask-injectoruv
uv add flask-injectorpoetry
poetry add flask-injectorInstalling Flask-Injector
Before you install
Low install friction with a pure-Python wheel distribution. Maintenance is dormant—last release was 2023-07-27, but the package is marked Production/Stable and has 282 repository stars. Suitable for established projects that don't require active upstream development.
License in practice
Licensed under BSD (permissive), which allows commercial and private use with minimal restrictions. No notable licensing constraints for typical adoption.
Quickstart
pip install Flask-Injector
from flask import Flask
from flask_injector import FlaskInjector
from injector import inject
app = Flask(__name__)
@app.route('/example')
def example(some_dependency):
return 'Injected'
def configure(binder):
binder.bind(str, to='injected_value')
FlaskInjector(app=app, modules=[configure])
app.run()
Requires Flask 2.2.0 or greater and Injector 0.20.0 or greater; compatible with CPython 3.7+.
Verify before relying
- Whether dormant maintenance (last commit 2024-05-08) poses compatibility risks with newer Flask or Injector versions.
- Real-world performance impact of dependency injection overhead in high-throughput Flask applications.
- Extent of community support or third-party maintenance if upstream development remains inactive.
Package facts
| License | BSD (permissive) |
| Python support | not specified |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — Flask, injector, typing |
| Maintenance | dormant — 1,114 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 106,151/month — #12,666 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: Flask_Injector-0.15.0-py2.py3-none-any.whl
Keywords: Dependency Injection, Flask
Tags
More Libraries packages
urllib3 is an HTTP client library that provides…
permissive · top 100 on PyPI
requestsRequests is a Python HTTP library that…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
python-dateutilProvides parsing, arithmetic, and recurrence…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
pytestpytest is a testing framework that lets you…
permissive · top 100 on PyPI
injectorInjector is a Python dependency injection…
permissive · top 5,000 on PyPI
dependency-injectorDependency Injector is a dependency injection…
permissive · top 5,000 on PyPI
fastapi-injectorIntegrates the injector dependency-injection…
permissive · top 15,000 on PyPI
injectProvides a lightweight dependency injection…
permissive · top 5,000 on PyPI
in-n-outLightweight dependency injection framework…
permissive · top 15,000 on PyPI
Flask-CachingFlask-Caching adds caching support to Flask…
permissive · top 5,000 on PyPI
Flask-GraphQLAdds a GraphQL endpoint to Flask applications,…
permissive · top 15,000 on PyPI
rodiRodi is a dependency injection container for…
permissive · top 15,000 on PyPI
allukaAlluka is a type-based dependency injection…
permissive · top 15,000 on PyPI
flask-corsFlask-CORS handles Cross-Origin Resource…
permissive · top 1,000 on PyPI