What is the difference between BaseHTTPServer and SimpleHTTPServer? When and where to use them? What is the difference between BaseHTTPServer and SimpleHTTPServer? When and where to use them? python python

What is the difference between BaseHTTPServer and SimpleHTTPServer? When and where to use them?


BaseHTTPServer is a HTTP server library. It understands the HTTP protocol and let your code handle requests. It doesn't have any "logic" on it's own. SimpleHTTPServer is built on top of BaseHTTPServer and handles requests in a similar way normal HTTP servers do, i.e. serve files from the file-system. In most cases you will want only BaseHTTPServer, as a base for implementing some development server for a web application.

If you are interested in working on a web application, not writing a HTTP server, you are probably looking for the WSGI interface. It allows you to write web aplications without depending on a specific server. There are also multiple frameworks that simplify the process.