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的更多相关文章

  1. Python 处理server返回gzip内容

    Python 如何处理server返回gzip压缩过的内容,代码如下: from StringIO import StringIOimport gzip request = urllib2.Reque ...

  2. 小测几种python web server的性能

    http://blog.csdn.net/raptor/article/details/8038476 因为换了nginx就不再使用mod_wsgi来跑web.py应用了,现在用的是gevent-ws ...

  3. Python Web Server Gateway Interface -- WSGI

    了解了HTTP协议和HTML文档,我们其实就明白了一个Web应用的本质就是: 浏览器发送一个HTTP请求: 服务器收到请求,生成一个HTML文档: 服务器把HTML文档作为HTTP响应的Body发送给 ...

  4. 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 ...

  5. python socket server源码学习

    原文请见:http://www.cnblogs.com/wupeiqi/articles/5040823.html 这里就是自己简单整理一下: #!/usr/bin/env python # -*- ...

  6. Notes on PEP333 (Python Web Server Gateway Interface)

    This note is about PEP3333- Python Web Server Gateway Interface. Refer to (Source: http://legacy.pyt ...

  7. python web server gateway interface (wsgi ) notes

    前言: 注:如果需要得到支持批Python3.x以及包含了勘误表,附录,和说明的更新版规范,请查看PEP 3333 摘要: 这篇文档详细说明了一套在web服务器与Python web应用程序(web框 ...

  8. Python游戏server开发日记(一)目标

    到了新的环境.老大让我有空研究下一代server技术,作为一个长期任务. 新的server想达到的目标: 1.分布式系统,对象(Entity)之间的关系类似于Actor模型. 2.逻辑服务,是单进程. ...

  9. C# 启动 a Python Web Server with Flask

    概览 最近有个需求是通过c#代码来启动python 脚本.嘿~嘿!!! 突发奇想~~既然可以启动python脚本,那也能启动flask,于是开始着手操作. 先看一波gif图 通过打开控制台启动flas ...

  10. python http server handle json

    用Python实现一个http server # python2 # coding = utf-8 from BaseHTTPServer import HTTPServer, BaseHTTPReq ...

随机推荐

  1. [转]在VS2010 VC++项目中引用Lib静态库(以Openssl为例)

    本文转自:http://kb.cnblogs.com/page/94467/ Openssl是个为网络通信提供安全及数据完整性的一种安全协议,囊括了主要的密码算法.常用的密钥和证书封装管理功能以及SS ...

  2. 每天学点GDB 15

    本节重点描述两个gdb集成测试环境 有没有办法在一边调试的时候,一边显示对应的源码呢?有没有一种工具能够将gdb集成到ide中呢,本文就试图回答这些问题. emacs gdb 在linux的世界里,e ...

  3. python 不得不知的第三方库以及常用安装包

    mysql 驱动$ sudo pip install MySQL-python redis 数据库$ sudo pip install redis django 全文搜索$ sudo pip inst ...

  4. 使用无限生命期Session的方法

    使用无限生命期Session的方法 [来源] 达内    [编辑] 达内   [时间]2013-03-28 Session储存在服务器端,根据客户端提供的SessionID来得到这个用户的文件,然后读 ...

  5. Rails--content_for和yield

    --使用: (1)layout中使用<%=yield(:js)%> (2)html中使用<% content_for :js do %>[XXX]<% end %>

  6. anti-pattern - Hard coding

    https://en.wikipedia.org/wiki/Hard_coding Considered an anti-pattern, hard coding requires the progr ...

  7. Java中的可变参数以及foreach语句

    Java中的可变参数的定义格式如下: 返回值类型  方法名称(类型 ... 参数名称){} foreach语句的格式如下: for ( 数据类型  变量名称 :数据名称){ ... } public ...

  8. poj1012约瑟夫

    #include<stdio.h>int a[14];int f(int k,int m){    int n,i,s;    n=2*k;s=0;    for(i=0;i<k;i ...

  9. EF的表连接方法Include()

    在EF中表连接常用的有Join()和Include(),两者都可以实现两张表的连接,但又有所不同. 例如有个唱片表Album(AlbumId,Name,CreateDate,GenreId),表中含外 ...

  10. SQL查询一周内过生日的用户

    SELECT birthday, )) + '-' + )) + '-' + )) AS datetime) AS Nbirthday FROM CRM_Customer WHERE birthday ...