html wsgi web server
- #!/usr/bin/env python3
- #-*- coding:utf-8 -*-
- '''
- '''
- def application(environ,start_response):
- start_response('200 ok',[('Content-Type', 'text/html')])
- body='
hello,%s !
' % (environ['PATH_INFO'][1:] or 'web') - return [body.encode('utf-8')]
- #!/usr/bin/env python3
- #-*- coding:utf-8 -*-
- '''
- '''
- from wsgiref.simple_server import make_server
- from wsgi_client import application
-
- httpd=make_server('', 10086,application)
- print('Serving HTTP on port 10086')
- httpd.serve_forever()
t@localhost untitled$ python3 wsgi_server.py
Serving HTTP on port 10086
127.0.0.1 - - [10/May/2016 14:28:21] "GET /talen HTTP/1.1" 200 22
127.0.0.1 - - [10/May/2016 14:28:27] "GET /max HTTP/1.1" 200 20
127.0.0.1 - - [10/May/2016 14:29:22] "GET /china HTTP/1.1" 200 22
127.0.0.1 - - [10/May/2016 14:29:22] "GET /favicon.ico HTTP/1.1" 200 28
127.0.0.1 - - [10/May/2016 14:29:34] "GET /US HTTP/1.1" 200 19
127.0.0.1 - - [10/May/2016 14:29:35] "GET /favicon.ico HTTP/1.1" 200 28
t@localhost untitled$ netstat -lntp |grep 10086
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 0.0.0.0:10086 0.0.0.0:* LISTEN 4397/python3
t@localhost untitled$ curl http://localhost:10086/talen
hello,talen !
t@localhost untitled$ curl http://localhost:10086/max
hello,max !