0
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler

class aaa(BaseHTTPRequestHandler):
    def do_GET(self):
        self.wfile.write("Hello World")

if __name__ == "__main__":
    server = HTTPServer(("", 8888), aaa)
    server.serve_forever()

It's a practice to create a web server in Python. but, I do not know how to check the results.

ρяσѕρєя K
  • 132,198
  • 53
  • 198
  • 213
신재현
  • 1
  • 1
  • Please clarify what you are trying to achieve. Are you writing a client or a server or both? The code is the sever side. Where do you want to check the result of which operation? Are you missing a client? Your browser could be your test client.for a http request. – rob2universe Jan 08 '17 at 07:42

1 Answers1

0

Open a web browser and type http://localhost:8888/ into the address bar. If you see Hello World, it worked. Otherwise, it didn't.

Whether or not it worked, you can see the actual results returned like this. Open a command prompt and type:

telnet localhost 8888

after the connection completes, type:

GET / HTTP/1.0

and hit enter twice.

Then the response from the web server should appear.

Robᵩ
  • 163,533
  • 20
  • 239
  • 308