www.webdeveloper.com
Results 1 to 3 of 3

Thread: Making a simple web server in Python.

  1. #1
    Join Date
    May 2011
    Posts
    2

    Making a simple web server in Python.

    code from:
    http://fragments.turtlemeat.com/pythonwebserver.php

    with "http://localhost/index.html" does nothing,
    with "http://localhost:81/index.html ", [note: port 81 used instead of port 80, port 80 was already in use], gave:
    >>>
    started httpserver...
    michaeleric-PC - - [29/May/2011 15:42:25] "GET /index.html HTTP/1.1" 200 -
    ----------------------------------------
    Exception happened during processing of request from ('127.0.0.1', 51159)
    Traceback (most recent call last):
    File "C:\Python31\lib\socketserver.py", line 281, in _handle_request_noblock
    self.process_request(request, client_address)
    File "C:\Python31\lib\socketserver.py", line 307, in process_request
    self.finish_request(request, client_address)
    File "C:\Python31\lib\socketserver.py", line 320, in finish_request
    self.RequestHandlerClass(request, client_address, self)
    File "C:\Python31\lib\socketserver.py", line 614, in __init__
    self.handle()
    File "C:\Python31\lib\http\server.py", line 352, in handle
    self.handle_one_request()
    File "C:\Python31\lib\http\server.py", line 346, in handle_one_request
    method()
    File "C:\Users\MySelf\Program\game_stuff\Python_Server_code_and_test\pythonweb\webserver.py", line 20, in do_GET
    self.wfile.write(f.read())
    File "C:\Python31\lib\socket.py", line 219, in write
    return self._sock.send(b)
    TypeError: must be bytes or buffer, not str
    ----------------------------------------
    ^C received, shutting down server
    >>>

    can someone help?

  2. #2
    Join Date
    May 2011
    Posts
    2
    was told the code works fine on linux.
    i was using windows7.

  3. #3
    Join Date
    Oct 2007
    Location
    Western Massachusetts, USA
    Posts
    387
    Seems it is crashing on line 20 where i'm guessing it is copying data from a text file into the socket's handle. Check file permissions?
    Computer programmer / web developer.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles