-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwsgi.py
55 lines (46 loc) · 1.91 KB
/
wsgi.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
from masonite.app import App
from bootstrap.start import app
from config import application
from pydoc import locate
'''
|--------------------------------------------------------------------------
| Instantiate Container And Perform Important Bindings
|--------------------------------------------------------------------------
|
| Some Service providers need important bindings like the WSGI application
| and the application configuration file before they boot.
|
'''
container = App()
container.bind('WSGI', app)
container.bind('Application', application)
'''
|--------------------------------------------------------------------------
| Bind all service providers
|--------------------------------------------------------------------------
|
| Let's register everything into the Service Container. Once everything is
| in the container we can run through all the boot methods. For reasons
| some providers don't need to execute with every request and should
| only run once when the server is started. Providers will be ran
| once if the wsgi attribute on a provider is False.
|
'''
for provider in container.make('Application').PROVIDERS:
locate(provider)().load_app(container).register()
for provider in container.make('Application').PROVIDERS:
located_provider = locate(provider)().load_app(container)
if located_provider.wsgi is False:
container.resolve(locate(provider)().load_app(container).boot)
'''
|--------------------------------------------------------------------------
| Get the application from the container
|--------------------------------------------------------------------------
|
| Some providers may change the WSGI Server like wrapping the WSGI server
| in a Whitenoise container for an example. Let's get a WSGI instance
| from the container and pass it to the application variable. This
| will allow WSGI servers to pick it up from the command line
|
'''
application = container.make('WSGI')