/
hello.py
51 lines (38 loc) · 1.04 KB
/
hello.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
""" Minimal helloworld application.
"""
from wheezy.http import HTTPResponse, WSGIApplication
from wheezy.routing import url
from wheezy.web.handlers import BaseHandler
from wheezy.web.middleware import (
bootstrap_defaults,
path_routing_middleware_factory,
)
class WelcomeHandler(BaseHandler):
def get(self):
response = HTTPResponse()
response.write("Hello World!")
return response
def welcome(request):
response = HTTPResponse()
response.write("Hello World!")
return response
all_urls = [
url("", WelcomeHandler, name="default"),
url("welcome", welcome, name="welcome"),
]
options = {}
main = WSGIApplication(
middleware=[
bootstrap_defaults(url_mapping=all_urls),
path_routing_middleware_factory,
],
options=options,
)
if __name__ == "__main__":
from wsgiref.simple_server import make_server
try:
print("Visit http://localhost:8080/")
make_server("", 8080, main).serve_forever()
except KeyboardInterrupt:
pass
print("\nThanks!")