Home > life is fun > How to create network servers in Python (HTTP, FTP, SMTP, SOAP, syslog, …)

How to create network servers in Python (HTTP, FTP, SMTP, SOAP, syslog, …)


How to create network servers in Python (HTTP, FTP, SMTP, SOAP, syslog, …)

This article lists solutions to create network servers in Python for different standard protocols: HTTP, FTP, SMTP, SOAP, syslog, WebDAV, …

This page was created on the 2009-03-04 and last edited on the 2011-10-20.

Python standard library

First, the standard library provides client and server implementation for several network protocols out of the box: see http://docs.python.org/library/internet.html

HTTP server

The Python standard library provides a simple HTTP server implementation:

By the way, the quickest and easiest way to serve a local directory via HTTP is to launch SimpleHTTPServer with two lines in a shell or a CMD window (be careful though, this server is not secure at all and should only be used for local tests, as it may expose your whole hard drive!). For example if you use Python 2.6 on Windows:

C:\Users\user>cd C:\test  

C:\test>c:\Python26\Lib\SimpleHTTPServer.py 8123 
Serving HTTP on 0.0.0.0 port 8123 ...

If you need better performance and features or a more complete HTTP protocol support, I would suggest CherryPy:

HTTP proxy

It is sometimes useful to develop a HTTP proxy in Python to filter or modify HTTP requests and responses. This page provides a lot of information about various HTTP proxies developped in Python: http://proxies.xhaus.com/python/

See also my module CherryProxy, a filtering HTTP proxy extensible in Python.

FTP server

Python does not provide any FTP server in the standard library. You may try pyftpdlib: http://code.google.com/p/pyftpdlib/

SMTP server

In the standard library, see the smtpd module: http://docs.python.org/library/smtpd.html

smtpd may be used as a SMTP server or as a relay.

SOAP server

XML-RPC server

See simplexmlrpcserver and docxmlrpcserver in the standard library:

Syslog server

WebDAV

Advertisements
Categories: life is fun
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: