view prezentacja-django-flask/hello_basehttp.py @ 30:50708627f3c7

Ukończona strona klienta
author mild@mild-laptop
date Sun, 05 Jun 2011 23:10:18 +0200
parents f73176cba39b
children
line wrap: on
line source

#!/usr/bin/python
# -*- coding: utf-8 -*-
import BaseHTTPServer

class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler):
    def do_HEAD(s):
		s.send_response(200)
		s.send_header("Content-type", "text/html")
		s.end_headers()
    def do_GET(s):
        if (s.path == "/witaj"):
			s.send_response(200)
			s.send_header("Content-type", "text/html")
			s.end_headers()
			s.wfile.write("Witaj Swiecie!")
        else:
            s.send_response(404)
            s.send_header("Content-type", "text/html")
            s.end_headers()
            s.wfile.write("404 not found")

if __name__ == '__main__':
    server_class = BaseHTTPServer.HTTPServer
    httpd = server_class(('localhost', 60085), MyHandler)
    try:
        httpd.serve_forever()
    except KeyboardInterrupt:
        pass
    httpd.server_close()