Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1778109
  • 博文数量: 276
  • 博客积分: 1574
  • 博客等级: 上尉
  • 技术积分: 2894
  • 用 户 组: 普通用户
  • 注册时间: 2010-05-26 23:23
个人简介

生活的美妙在于,不知道一下秒是惊艳还是伤神,时光流转,珍惜现在的拥有的时光

文章分类

全部博文(276)

文章存档

2017年(17)

2016年(131)

2015年(63)

2013年(2)

2012年(32)

2011年(31)

分类: Python/Ruby

2016-05-10 14:32:03

html <-> wsgi <-> web server

点击(此处)折叠或打开

  1. #!/usr/bin/env python3
  2. #-*- coding:utf-8 -*-
  3. '''
  4. '''
  5. def application(environ,start_response):
  6.     start_response('200 ok',[('Content-Type', 'text/html')])
  7.     body='

    hello,%s !

    '
    % (environ['PATH_INFO'][1:] or 'web')
  8.     return [body.encode('utf-8')]


点击(此处)折叠或打开

  1. #!/usr/bin/env python3
  2. #-*- coding:utf-8 -*-
  3. '''
  4. '''
  5. from wsgiref.simple_server import make_server
  6. from wsgi_client import application

  7. httpd=make_server('', 10086,application)
  8. print('Serving HTTP on port 10086')
  9. 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

hello,talen !


t@localhost untitled$ curl

hello,max !







阅读(1063) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~