Reputation: 314
Hi I am trying to create a web server with python but I am getting an error message PermissionError: [Errno 13] Permission denied
This is my code:
import os, sys
from http.server import HTTPServer, CGIHTTPRequestHandler
webdir = '.'
port = 80
os.chdir(webdir)
srvaddr = ('', port)
srvobj = HTTPServer(srvaddr, CGIHTTPRequestHandler)
srvobj.serve_forever()
Upvotes: 9
Views: 11367
Reputation: 59553
Try changing the port to 8080. You didn't say which OS, but most UNIX derivatives will only allow root
to listen on ports below 1,024 or 4,096 depending on the OS and its configuration.
Upvotes: 14