Python >> Ruby :-)
This commit is contained in:
parent
73bc23d165
commit
534c42e2d5
|
@ -1,6 +1,35 @@
|
||||||
[[Category:Ruby]] [[Category:Python]]
|
[[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">
|
<source lang="python">
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
Loading…
Reference in New Issue
Block a user