How to set up web service by python?

Diez B. Roggisch deets at nospam.web.de
Sat Oct 24 15:15:38 EDT 2009


Peng Yu schrieb:
> I'm following the instruction on
> http://fragments.turtlemeat.com/pythonwebserver.php to set web
> service. But I get the following error message when I run the script
> on my mac machine. I'm wondering why I see the permission denied error
> message.
> 
> $python webserver.py
> Traceback (most recent call last):
>   File "webserver.py", line 63, in <module>
>     main()
>   File "webserver.py", line 55, in main
>     server = HTTPServer(('', 80), MyHandler)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/SocketServer.py",
> line 330, in __init__
>     self.server_bind()
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/BaseHTTPServer.py",
> line 101, in server_bind
>     SocketServer.TCPServer.server_bind(self)
>   File "/System/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/SocketServer.py",
> line 341, in server_bind
>     self.socket.bind(self.server_address)
>   File "<string>", line 1, in bind
> socket.error: (13, 'Permission denied')

As you don't show us the code, I can only guess - but experience tells 
me that you try & bind your service to a priviledged (<=1024) port, 
which *nix only allows with root-privileges.

Diez



More information about the Python-list mailing list