Mercurial > kraina_muminkow
comparison 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 |
comparison
equal
deleted
inserted
replaced
25:3a26da290650 | 26:f73176cba39b |
---|---|
1 #!/usr/bin/python | |
2 # -*- coding: utf-8 -*- | |
3 import BaseHTTPServer | |
4 | |
5 class MyHandler(BaseHTTPServer.BaseHTTPRequestHandler): | |
6 def do_HEAD(s): | |
7 s.send_response(200) | |
8 s.send_header("Content-type", "text/html") | |
9 s.end_headers() | |
10 def do_GET(s): | |
11 if (s.path == "/witaj"): | |
12 s.send_response(200) | |
13 s.send_header("Content-type", "text/html") | |
14 s.end_headers() | |
15 s.wfile.write("Witaj Swiecie!") | |
16 else: | |
17 s.send_response(404) | |
18 s.send_header("Content-type", "text/html") | |
19 s.end_headers() | |
20 s.wfile.write("404 not found") | |
21 | |
22 if __name__ == '__main__': | |
23 server_class = BaseHTTPServer.HTTPServer | |
24 httpd = server_class(('localhost', 60085), MyHandler) | |
25 try: | |
26 httpd.serve_forever() | |
27 except KeyboardInterrupt: | |
28 pass | |
29 httpd.server_close() |