John
John

Reputation: 2147

is apache necessary while we have python's built-in SimpleHttpServer

I am new to the python web dev world and kind of confused about why we need a apache enviroment while we could run python web app with its build-in http sever? Also, from my experience, I could run an django app without setting up anything else. then why we still need apache + mod_wsgi? for performance?

actually what really confuse me is.... how my entry point of code should be written? e.g. I heard there are other advanced 'web server' as well like cherrypy/Tornado and every single of them will require different entry-point code. so I wonder if apache(+ mod_wsgi) is not overlapping with other web framework(I called them web server above)? (in most case) we should be using apache on production but use others as an 'addon'? thanks

Upvotes: 3

Views: 3666

Answers (5)

Graham Dumpleton
Graham Dumpleton

Reputation: 58523

These days the standard entry point is a WSGI application object. Pretty well everything supports it. How each web framework exposes one, and how you set up each WSGI hosting mechanism to then use it is different. At the core though, the actual interface between web server and application is the same.

Upvotes: 2

Eduardo Ivanec
Eduardo Ivanec

Reputation: 11852

Yes, in general you need those for performance.

If you want to avoid the complexity of setting up Apache until you really have to (which could be reasonable if you're short on time and/or lack experience) you will probably be better off by using CherryPy to serve Django. It has an all-Python web server with much better performance than the built-in.

You can find instructions for that here.

Upvotes: 0

01100110
01100110

Reputation: 2344

Performance and scalability would be the reasons to go with Apache in production. SimpleHTTPServer is fine for testing and internal use though.

Upvotes: 0

wvdschel
wvdschel

Reputation: 11838

Performance, stability, scalability, security, ...

The built in HTTP server is useful for simple testing or quickly running a web app on your development machine, but is in no way as scalable as the Apache server. Security will also likely be less hardened on the built-in one.

Also, Apache allows you to handle many extra things, such as vhosts, multiple kinds of server-side platforms (for instance, a Ruby on Rails app and a Django one on the same port/IP), which are harder to achieve with the built-in server.

Upvotes: 8

Amandasaurus
Amandasaurus

Reputation: 60699

Apache is way better than the python SimpleHTTPServer.

For one thing the SimpleHttpServer is single threaded, but apache can easily handle multiple threads. Apache can also be configured in many ways that SimpleHttpServer cannot do. Apache has an easy to use logging of requests, which is helpful for debugging & logging.

Upvotes: 2

Related Questions