web hello word
来源:互联网 发布:淘宝如何自动发货 编辑:程序博客网 时间:2024/05/18 20:11
原文:http://www.liaoxuefeng.com/wiki/001374738125095c955c1e6d8bb493182103fac9270762a000/001386832689740b04430a98f614b6da89da2157ea3efe2000
hello.py
# coding:utf-8
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/html')])
return '<h1>Hello, web!</h1>'
server.py
# coding:utf-8
# 从wsgiref模块导入:
from wsgiref.simple_server import make_server
# 导入我们自己编写的application函数:
from hello import application
# 创建一个服务器,IP地址为空,端口是8000,处理函数是application:
httpd = make_server('', 8000, application)
print "Serving HTTP on port 8000..."
# 开始监听HTTP请求:
httpd.serve_forever()
终端中进入server.py所在的目录,执行 python server.py
wooddeMacBook-Pro:www wood$ python server.py
Serving HTTP on port 8000...
127.0.0.1 - - [20/May/2015 09:48:57] "GET / HTTP/1.1" 200 20
127.0.0.1 - - [20/May/2015 09:48:57] "GET /favicon.ico HTTP/1.1" 200 20
这样8000端口就跑起来了,我们在web浏览器中输入 localhost:8000
页面显示:
hello word!
第一个web hello 运行啦
- web hello word
- web.py的hello word演示
- hello word
- hello word
- Hello,Word?
- hello word!
- Hello Word
- hello word
- hello word
- hello word!
- hello word
- Hello Word
- hello word!
- Hello Word
- Hello word!
- Hello word!
- Hello word
- Hello Word!
- 面试算法---排列组合AC的实现
- 数据挖掘之计算距离
- Cook来中国 苹果支付与支付宝合作或将进一步推进
- GUI架构方法
- 中网BAT联手“移动互联网+”意欲何为?
- web hello word
- 研究关于安卓中转跳转时黑屏的现象
- 天声人語 20150520
- OpenGL ES 的 EGL
- (9)安装GPIO库
- Android Studio cvs 状态颜色
- Flask、Django、Pyramid三个框架的对比
- Xwiki使用说明书
- 黑马程序员———网络编程