Skip to content

Commit 4ec9ad8

Browse files
committed
add wsgi app
1 parent 1dff390 commit 4ec9ad8

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

py3/web/do_wsgi.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
from wsgiref.simple_server import make_server
5+
6+
from hello import application
7+
8+
httpd = make_server('', 8000, application)
9+
print('Serving HTTP on port 8000...')
10+
11+
httpd.serve_forever()

py3/web/hello.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/usr/bin/env python3
2+
# -*- coding: utf-8 -*-
3+
4+
def application(environ, start_response):
5+
start_response('200 OK', [('Content-Type', 'text/html')])
6+
body = '<h1>Hello, %s!</h1>' % (environ['PATH_INFO'][1:] or 'web')
7+
return [body.encode('utf-8')]

0 commit comments

Comments
 (0)