Python >> Ruby :-)

This commit is contained in:
Toidinamai 2007-11-14 20:47:37 +00:00
parent 73bc23d165
commit 534c42e2d5
1 changed files with 30 additions and 1 deletions

View File

@ -1,6 +1,35 @@
[[Category:Ruby]] [[Category:Python]]
=Python=
=Python (base library)=
<source lang="python">
#!/usr/bin/env python
import sys
import os
from SocketServer import ThreadingMixIn
from BaseHTTPServer import HTTPServer
from SimpleHTTPServer import SimpleHTTPRequestHandler
class ThreadingHTTPServer(ThreadingMixIn, HTTPServer):
pass
if len(sys.argv) != 3:
print "Usage: %s <port> <dir>" % (sys.argv[0],)
sys.exit()
address = ('', int(sys.argv[1]))
server = ThreadedHTTPServer(address, SimpleHTTPRequestHandler)
os.chdir(sys.argv[2])
try:
server.serve_forever()
except KeyboardInterrupt:
pass
</source>
=Python (Twisted)=
<source lang="python">
#!/usr/bin/env python