forked from github/pelican
Creating a more explicit error message at server creation
This commit is contained in:
parent
c3e9d0e96e
commit
7fa0d3063d
1 changed files with 7 additions and 1 deletions
|
|
@ -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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue