1
0
Fork 0
forked from github/pelican

Creating a more explicit error message at server creation

This commit is contained in:
Félix Delval 2013-03-16 19:29:10 +01:00
commit 7fa0d3063d

View file

@ -1,4 +1,5 @@
from __future__ import print_function
import sys
try:
import SimpleHTTPServer as srvmod
except ImportError:
@ -13,7 +14,12 @@ PORT = 8000
Handler = srvmod.SimpleHTTPRequestHandler
httpd = socketserver.TCPServer(("", PORT), Handler)
try:
httpd = socketserver.TCPServer(("", PORT), Handler)
except OSError as e:
print("Could not listen on port", PORT)
sys.exit(getattr(e, 'exitcode', 1))
print("serving at port", PORT)
httpd.serve_forever()