New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running In Serverless Lambda Using serverless-wsgi #54
Comments
I'm not entirely sure what this question is about. It'd help if you could provide
|
init_app.py from flask import Flask
from flask_restful import Api
from flask_injector import FlaskInjector
from injector import Module, singleton, provider
app = Flask(__name__)
api = Api(app)
class InjectorModule(Module):
@singleton
@provider
def provide_email_client(self) -> EmailClient:
return SesClient(some_region)
flask_injector = FlaskInjector(app=app, modules=[InjectorModule])
from src.resources import *
app.register_blueprint(routes)
app.app_context().push() some resource file class SomeResource(Resource):
@inject
def __init__(self, email_client: EmailClient):
self.email_client = email_client
def post(self):
# some code using self.email_client
the exception:
Stacktrace:
Python: 3.7 Anything else? :D TBH the code doesn't run |
flask_injector = FlaskInjector(app=app, modules=[InjectorModule])
from src.resources import *
app.register_blueprint(routes) Registering all views (even those owned by blueprints) needs to happen before |
Hollllllllllllllly :D My bad, this solved my problem. Thanks soooooooooooooooooo much <3 |
No worries, good to hear it's working for you now. Also this should be documented better I think :) |
Hello,
Is there a way to use this package without
app.run()
where serverless doesnt require running the app using the aforementioned command?When using this package, for some reason I can't use "contructor injection", nor
injector.get(INTERFACE)
but this works:Thanks :D
The text was updated successfully, but these errors were encountered: