Mercurial > kraina_muminkow
diff prezentacja-django-flask/hello_basehttp.py @ 26:f73176cba39b
Zacząłem pracę nad prezentacją
author | Michał Rudowicz <michal.rudowicz@fl9.eu> |
---|---|
date | Fri, 13 May 2011 16:37:29 +0200 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/prezentacja-django-flask/hello_basehttp.py Fri May 13 16:37:29 2011 +0200 @@ -0,0 +1,29 @@ +#!/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()