python 简单的server请求

1.代码

#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# __author henry
# __date 2018/11/4

from wsgiref.simple_server import make_server

def application(environ, start_response):
    start_response('200 ok', [('Content-Type', 'text/html')])
    return [b'<h1>hello, web!</h1>']

httpd = make_server('', 8080, application)

print('serving Http oN port 8000...')
# 开始监听HTTP请求
httpd.serve_forever()

2. 执行 run

 

3.浏览器响应

 

posted @ 2018-11-04 22:08  侠岚之弋痕夕  阅读(313)  评论(0编辑  收藏  举报
Where is the starting point, we don't have a choice, but the destination where we can pursue!