example of Python http server
from BaseHTTPServer import HTTPServer, BaseHTTPRequestHandler print "hello " class TestHTTPHandle(BaseHTTPRequestHandler):
def do_GET(self): print self.client_address
print self.command buf = 'It works' self.protocal_version = "HTTP/1.1" print "yes no" self.send_response(200) self.send_header("Welcome", "Contect") self.end_headers() self.wfile.write(buf)
def do_POST(self):
buf = 'yes' def start_server(port):
#Create the pbject and server requests
# serveaddr=('',8000)
# httpd=HTTPServer(serveaddr,TestHTTPHandler)
# print "Base serve is start add is %s port is %d"%(serveaddr[0],serveaddr[1])
# httpd.serve_forever() # handle = TestHTTPHandle() http_server = HTTPServer(('127.0.0.1', int(port)), TestHTTPHandle)
http_server.serve_forever()
print "start server" start_server(8000)
example of Python http server的更多相关文章
- Python 处理server返回gzip内容
Python 如何处理server返回gzip压缩过的内容,代码如下: from StringIO import StringIOimport gzip request = urllib2.Reque ...
- 小测几种python web server的性能
http://blog.csdn.net/raptor/article/details/8038476 因为换了nginx就不再使用mod_wsgi来跑web.py应用了,现在用的是gevent-ws ...
- Python Web Server Gateway Interface -- WSGI
了解了HTTP协议和HTML文档,我们其实就明白了一个Web应用的本质就是: 浏览器发送一个HTTP请求: 服务器收到请求,生成一个HTML文档: 服务器把HTML文档作为HTTP响应的Body发送给 ...
- a simple and universal interface between web servers and web applications or frameworks: the Python Web Server Gateway Interface (WSGI).
WSGI is the Web Server Gateway Interface. It is a specification that describes how a web server comm ...
- python socket server源码学习
原文请见:http://www.cnblogs.com/wupeiqi/articles/5040823.html 这里就是自己简单整理一下: #!/usr/bin/env python # -*- ...
- Notes on PEP333 (Python Web Server Gateway Interface)
This note is about PEP3333- Python Web Server Gateway Interface. Refer to (Source: http://legacy.pyt ...
- python web server gateway interface (wsgi ) notes
前言: 注:如果需要得到支持批Python3.x以及包含了勘误表,附录,和说明的更新版规范,请查看PEP 3333 摘要: 这篇文档详细说明了一套在web服务器与Python web应用程序(web框 ...
- Python游戏server开发日记(一)目标
到了新的环境.老大让我有空研究下一代server技术,作为一个长期任务. 新的server想达到的目标: 1.分布式系统,对象(Entity)之间的关系类似于Actor模型. 2.逻辑服务,是单进程. ...
- C# 启动 a Python Web Server with Flask
概览 最近有个需求是通过c#代码来启动python 脚本.嘿~嘿!!! 突发奇想~~既然可以启动python脚本,那也能启动flask,于是开始着手操作. 先看一波gif图 通过打开控制台启动flas ...
- python http server handle json
用Python实现一个http server # python2 # coding = utf-8 from BaseHTTPServer import HTTPServer, BaseHTTPReq ...
随机推荐
- Android shell 命令总结
Package Manage(PM) pm list packages [FILTER] 查看已安装的应用包 -f 显示关联的apk文件 -s 只在系统应用中搜索Filter -3 只在第三方应用中搜 ...
- linux 防火墙设置
防火墙的基本操作命令: 查询防火墙状态:[root@localhost ~]# service iptables status<回车> 停止防火墙:[root@localhost ~]# ...
- 高手指南PHP安装配置
高手指南PHP安装配置 2014-11-05 12:57:13 来源: 评论:0 次 点击:12 次 | 发布人:登陆查看 PHP的快速发展,它的功能越来越强大,运用它也变得很方便,下面我 ...
- yum 安装mysql5.6
系统centos5.5 进入http://dev.mysql.com/downloads/repo/,下载RedHat Enterprise Linux 5 / Oracle Linux 5版. 点击 ...
- hbase基本命令
基本命令 建表scores 具有两个列族grad 和courese create 'scores','grade', 'course' 查看当前HBase中具有哪些表 list 查看表结构 des ...
- Summary of java stream classes
Java’s stream classes are good for streaming sequences of bytes, but they’re not good for streaming ...
- ADO.NET实体数据模型使用探索1
今天研究了下ADO.NET实体数据模型,想写个关于两张有外键关系的增改删查,以此来稍增加点难度. 编程环境:vs2010+sql2005 1.在SQL2005下建立三张表:学生信息表Student(S ...
- php apc
APC,全称是Alternative PHP Cache,官方翻译叫”可选PHP缓存”.它为我们提供了缓存和优化PHP的中间代码的框架. APC的缓存分两部分:系统缓存和用户数据缓存. 系统缓存 它是 ...
- asp.net字符串的数学表达式计算结果
using System; using System.Collections.Generic; using System.Web; using System.CodeDom.Compiler; usi ...
- 【python PIL学习】给照片打水印
不知道别人是怎么做的,闲着无聊就根据前几天看到的一些PIL里面的函数,写了这个小程序,经过测试,基本可以给所有像宽400以上的图片打上从左下到右上的看上去质量尚可的水印,更小的图片水印偏下.写完觉得很 ...