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. Jquery--array

    --遍历数组 $.each(Array, function(i, value) { this; //this指向当前元素 i; //i表示Array当前下标 value; //value表示Array ...

  2. Amoeba基本配置

    Amoeba安装及读写分离配置一.amoeba简介官网:http://docs.hexnova.com/amoeba/index.html二.Centos下安装jdk1.yum 安装1.6版本jdk2 ...

  3. PHP iconv()函数转字符编码的问题(转)

    PHP iconv()函数转字符编码的问题(转) 载自:http://www.nowamagic.net/php/php_FunctionIconv.php 在php函数库有一个函数:iconv(), ...

  4. ssi服务器端指令

    SSI使用详解 你是否曾经或正在为如何能够在最短的时间内完成对一个包含上千个页面的网站的修改而苦恼?那么可以看一下本文的介绍,或许能够对你有所帮助.什么是SSI?SSI是英文Server Side I ...

  5. 使用AJAX做关键字查询:输入框变化自动搜索、无刷新页面;

    使用AJAX做关键字查询要求:1.无刷新页面2.输入框变化自动搜索 <style type="text/css"> .k{ width:150px; height:30 ...

  6. 网页中的超链接<a>标签

    格式: <a href="目标网址" title="鼠标滑过显示的文本">链接显示的文本</a> 注意:为文本加入<a>标签 ...

  7. Jquery 多选下拉列表插件jquery multiselect

    有一个多选的需求,在网上找到了这个插件:multiselect https://github.com/ehynds/jquery-ui-multiselect-widget csdn博客上有这个插件的 ...

  8. Shell Script-读取配置文件

    需求 有时候在shell script里面需要一些执行,如果放在程序里面不便于统一管理,并且每一次修改路径都要去script里面改好麻烦,所以统一把路径放在配置文件中方便管理. 问题 如何读取相对应的 ...

  9. web调试工具-firebug

    Firebug是网页浏览器firefox下面的一款开发类插件.它集HTML查看和编辑,js控制台,网络状况监视器于一体,是开发js,css,HTML:和Ajax的得力助手 (自己整理的,有错误的话见谅 ...

  10. jQuery控制DOM对象

    <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <m ...