M
M
Maga Izdaga2021-07-27 21:44:06
Python
Maga Izdaga, 2021-07-27 21:44:06

Am I understanding this principle correctly?

I studied the principle of the web server and felt that I have a gap in understanding what WSGI is, or rather, I know what it is, speaking by definition, but in my own words it is difficult to explain. In short, right now I will just write a sequence of actions that, in my opinion, occur when a request hits the server where some kind of web application is located, and you will just have to point out where I was wrong. So that in case of misunderstanding the root of the problem of ignorance is clearly visible, I will write the whole process in brief.

In general, an HTTP request hit the server, or rather, the web server, it sends this request to the application server, which in turn launches the WSGI server, to which the request data is transmitted, the WSGI server has a handler that already accesses the web application itself , but suppose that there is a framework in front of it, the framework receives more portions of data from the WSGI server and translates them into a form understandable for the developer so that he can work with it, the framework gives the necessary APIs for creating applications, then an html page is generated in the application, given WSGI server, it gives it back to the application server, it gives it to the web server in the HTTP response format, it gives it to the client (browser), which, in the presence of some additional files, is necessary for the page (css, java scripts, etc.) , addresses the server again,that through a web server receives static files and gives back.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
J
javedimka, 2021-07-28
@MagaVTanke

he sends this request to the application server, which in turn starts the WSGI server, to which the request data is transmitted

No, the WSGI server is started once.
the WSGI server has a handler that already refers to the web application itself

No, the WSGI server has no dependencies on your application.
the framework receives more portions of data from the WSGI server and translates them into a form understandable for the developer

No, the framework does not receive more portions of data from the WSGI server, it receives exactly the same as the application without the framework.
then an html page is generated in the application, given to the WSGI server, which gives it back to the application server

No, the WSGI server receives data in the format defined by the WSGI standard.
WSGI server is just a layer between a "web" server and a python application, which allows you not to think about choosing a "web" server and / or framework on which the application will be written.
The WSGI server is run once, fired at a special object defined by the WSGI standard, this object is written by the application developer, or by the framework developer if a framework is used. (not always)
When an HTTP request comes from the "web" server, the WSGI server processes this request, parses it into a structure defined by the standard, and calls the very special object defined by the WSGI standard, which does things defined by the WSGI standard, namely, using the object passed in the parameters , sends the HTTP response code and response headers to the WSGI server, and then returns a generator that will return the response body. The WSGI server from this whole thing brews an HTTP response and returns it to the "web" server.
You can get headers and body as you like - you can do it using a framework like django / flask, or just read from a file.
Just read the PEP:
https://www.python.org/dev/peps/pep-3333/#environ-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question