Mercurial > kraina_muminkow
view prezentacja-django-flask/hello_basehttp.py @ 28:d017e2ab3027
Poprawki z rana 23 maja, prezentacja django-flask
author | Michał Rudowicz <michal.rudowicz@fl9.eu> |
---|---|
date | Mon, 23 May 2011 12:49:48 +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()