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 ...
随机推荐
- service mongod start start: Unknown job: mongod问题
终于解决了这个异常蛋疼的问题,当安装完毕mongodb的时候,执行: root@ubuntu:/usr/local# service mongod start 出现: start: Unknown j ...
- 使用spring等框架的web程序在Tomcat下的启动顺序及思路理清
大牛请绕过,此文仅针对自己小白水平,对web程序的启动流程做个清晰的回顾. 一.使用spring等框架的web程序在Tomcat下的启动流程 1)Tomcat是根据web.xml来启动的.首先到web ...
- tmux使用笔记
tmux是指通过一个终端登录远程主机并运行后,在其中可以开启多个控制台的终端复用软件. 安装tmux需要先安装依赖包libevent,因为libevent安装在临时位置,所以在编译tmux过程中用到n ...
- linux 常用的基本命令
$ ls # 查看文件列表 $ ls dir_name | more : 分页查看文件列表 $ ll -h dir_name # 以 KB.MB.GB格式查看文件大小 $ ll -Sh # --so ...
- [转]为何TCP/IP协议栈设计成沙漏型的
http://m.blog.csdn.net/blog/dog250/18959371 前几天有人回复我的一篇文章问,为何TCP/IP协议栈设计成沙漏型的.这个问题问得好!我先不谈为何它如此设计,我一 ...
- jquery 选择器,模糊匹配
按姓名匹配 1,name前缀为aa的所有div的jquery对象 $("div[name^='aa']"); 2,name后缀为aa的所有div的jquery对象 $(" ...
- prototype linkage can reduce object initialization time and memory consumption
//对象是可变的键控集合, //"numbers, strings, booleans (true and false), null, and undefined" 不是对象的解释 ...
- Android之Fragment学习笔记①
Android Fragment完全解析,关于碎片你所需知道的一切 一. 什么是FragmentFragment(碎片)就是小型的Activity,它是在Android3.0时出现的.Fragment ...
- 详解linux系统的启动过程及系统初始化
一.linux系统的启动流程 关于linux系统的启动流程我们可以按步进行划分为如下: POST加电自检 -->BIOS(Boot Sequence)-->加载对应引导上的MBR(boot ...
- 局部变量、结构体和main函数
在函数中定义的变量称为自动局部变量.因为每次调用该函数时,它们都自动“创建”,并且它们的只对于函数来说是局部的,局部对象的变量都会默认为空.局部变量的值只能在定义该变量的函数中访问,不能从函数之外访问 ...