3

I know that in order to run a Python web application(an application developed with frameworks such as Flask & Django) on the server, you need to deploy it using things such as uwsgi, wsgi.. gunicorn.. etc, and configure it to run with the web servers like apache2 & nginx.

But, I know that I can just run python my_app.py and the application will work on the server using the ports like: mywebsite.com:5000. And I can use a proxy on the web server to redirect mywebsite.com:5000 to something like test.example.com or any place I want.

So what's the difference between the two ways? Which one should I use?

Thanks.

0

This isn't the case with all frameworks but django and flask when you run in their dev http mode, which you referenced, is only single threaded.

So the server can only handle a single connection at a time. So if two connections come in together the server will handle one and make the other wait.

A wsgi server with apache/nginx in front will handle many connections at once.

  • Isn't there an alternative way to run the application in multi-thread using the same python command without using wsgi and others? – userofserver Aug 23 '15 at 14:52
  • that really depends on the framework you are using. – Mike Aug 23 '15 at 20:00
  • Even when you use a builtin development server you are still using WSGI. WSGI is the API by which modern Python web applications talk to a web server. So all modern sync frameworks rely on WSGI. Where you are confusing things is by saying 'wsgi' is an implementation of WSGI when it isn't. You likely mean 'mod_wsgi' and if that is the case that is what you should refer to it as. It is very rare to find a sync framework which isn't setup to run on top of a WSGI server. The main Python web frameworks that don't are actually async frameworks as there is not standard API for async. – Graham Dumpleton Aug 23 '15 at 21:01

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.