mirror of
https://github.com/getpelican/pelican.git
synced 2025-10-15 20:28:56 +02:00
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
|
from __future__ import print_function
|
||||||
|
import sys
|
||||||
try:
|
try:
|
||||||
import SimpleHTTPServer as srvmod
|
import SimpleHTTPServer as srvmod
|
||||||
except ImportError:
|
except ImportError:
|
||||||
|
|
@ -13,7 +14,12 @@ PORT = 8000
|
||||||
|
|
||||||
Handler = srvmod.SimpleHTTPRequestHandler
|
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)
|
print("serving at port", PORT)
|
||||||
httpd.serve_forever()
|
httpd.serve_forever()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue