471,329 Members | 1,898 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,329 software developers and data experts.

Http protocol Script

Hi,
I am new to Python and wrote a http protocol script. I got this error please slove this

my server:::



import string,cgi,time

from os import curdir, sep

from BaseHTTPServer import BaseHTTPRequestHandler, HTTPServer





class MyHandler(BaseHTTPRequestHandler):



def do_GET(self):

try:
send_response(200)

send_header('Content-type','text/html')

send_headers()





except IOError:

send_error(404,'File Not Found: %s' % self.path)


def xyz():

send_responce(200)
send_headers('Content_type','text/html')







def main():

try:

server = HTTPServer(('',50), MyHandler)

print 'started httpserver...'

server.serve_forever()

except KeyboardInterrupt:

print '^C received, shutting down server'

server.socket.close()



if __name__ == '__main__':

main()





My client:::

import httplib

conn=httplib.HTTPConnection('localhost',50)
conn.request('xyz','index.esp')
r=conn.getresponse()
print r.status


Error I got:::

localhost.localdomain - - [14/Sep/2007 11:43:53] code 501, message Unsupported method ('xyz')
localhost.localdomain - - [14/Sep/2007 11:43:53] "xyz index.esp HTTP/1.1" 501
Sep 14 '07 #1
0 860

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

8 posts views Thread by turnit \(removethis\) | last post: by
4 posts views Thread by Bob Badger | last post: by
7 posts views Thread by =?Utf-8?B?YzY3NjIyOA==?= | last post: by
reply views Thread by allavarapu | last post: by
1 post views Thread by welcomestocontact | last post: by
6 posts views Thread by hpatel | last post: by
7 posts views Thread by Chris | last post: by
reply views Thread by rosydwin | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.