How to set up web service by python?

P

Peng Yu

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')
 
D

Diez B. Roggisch

Peng said:
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
 
E

Edward A. Falk

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.

Concur.

You need root privileges to run any service on port 80. Try using 8080
instead.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,813
Messages
2,569,696
Members
45,483
Latest member
TedDvb6626

Latest Threads

Top