Répondre au commentaire

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

 

Répondre

Le contenu de ce champ ne sera pas montré publiquement.
  • Les adresses de pages web et de messagerie électronique sont transformées en liens automatiquement.
  • Allowed HTML tags: <a> <b> <address> <blockquote> <br> <caption> <center> <code> <dd> <del> <div> <dl> <dt> <em> <font> <h2> <h3> <h4> <h5> <h6> <hr> <i> <img> <li> <ol> <p> <pre> <span> <strong> <sub> <sup> <table> <tbody> <td> <tfoot> <th> <thead> <tr> <u> <ul> <tr>
  • Les lignes et les paragraphes vont à la ligne automatiquement.
  • You can enable syntax highlighting of source code with the following tags: <code>, <blockcode>. The supported tag styles are: <foo>, [foo].
  • Insérer [toc list: ol; title: Table of Contents; minlevel: 2; maxlevel: 3; attachments: yes;] pour afficher une table des matières déroulable de style MediaWiki. Tous les arguments sont optionnels.

Plus d'informations sur les options de formatage

By submitting this form, you accept the Mollom privacy policy.