Answer the question
In order to leave comments, you need to log in
How does the python server work?
Hello everyone, can you tell me or throw me a link to information about the work of nginx + python?
There is a certain code smeared with async / await, all client requests are transmitted through nginx.
Do I understand correctly that when nginx + python is running, the scheme of work is similar to nginx + php-fpm, where in nginx we can specify the maximum number of processes to start, and new threads are also created for the python application. Or is nginx only needed to pass the request, and python works like a typical threaded node.js application?
Answer the question
In order to leave comments, you need to log in
It depends on how your application is written.
If it's ASGI (FastAPI for example) then some Uvicorn or Daphne will do .
If you have WSGI (Django or Flask for example) then you can use servers like Gunicorn or uWSGI as an option.
There are such frameworks/libraries where the production versions of the servers are included in the framework/library itself. For example , tornado or aiohttp
Nginx is needed here rather for balancing or distributing statics. But the latter is not necessarily through Nginx. For example, for WSGI applications, you can use WhiteNoise (here is an example withheroku ).
But you can also set up balancing not only through nginx. It all depends on where and why you need it. Here they already threw off the option with traefik, for example.
Hello.
The easiest way is ngix + Flask (Django) or other options that you can find.
Nginx will not run Python files (it may be possible, but this is dancing with a tambourine and a perversion, as for me).
If you basically do not want a web server. Try to look at unix plugins in more detail: Gunicorn or uWSGI .
With a certain straightness, you get what you wanted.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question