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. linux load average

    性能分析_linux服务器CPU_Load Average 理解Linux系统中的load average(图文版) 理解Load Average做好压力测试 top命令的Load average 含 ...

  2. 投芯片,现在要n+1模式

    给坚持理想的屌丝点个赞.投芯片,现在要n+1模式,n个小项目+一个大项目.团队是基础,屌丝创业要以营利为先导,先要短快,同时要有并行的大项目支撑.小项目赚的钱先解决面包问题,同时为大项目锻炼队伍积累经 ...

  3. maven Ubuntu14.04 安装

    参考:linux上安装使用maven 下载链接:官网Download 解压. 在root用户下执行: cd /opt mkdir maven chmod 755 /opt/maven tar -zvx ...

  4. The P4 Language Specification v1.0.2 Parser

    <p4规范>解析器部分详解 p4解析器是根据有限状态机的思想来设计的. 解析器中解析的过程可以被一个解析图(parser graph)所表示,解析图中所表示的某一个状态(或者说,在P4语言 ...

  5. HTML / JavaScript / PHP 实现页面跳转的几种方式

    ① HTML 的 meta refresh 标签 <!doctype html> <html lang="en"> <head> <met ...

  6. PHP正则表达式及实例

    PHP正则表达式及实例 博客分类: Php / Pear / Mysql / Node.js 正则表达式PHPWordPressFPApache  关联: 正则表达式 去除连续空白 + 获取url + ...

  7. 发现美的眼睛 Prepared SQL Statement

    DROP PROCEDURE IF EXISTS truncate_insert_sales_rank_toparow_month; DELIMITER /w/ CREATE PROCEDURE tr ...

  8. Apache Apex

    http://apex.apache.org/docs.html https://apex.apache.org/docs/apex/application_development/

  9. c语言学习上的思考与心得

    由于这段时间在c语言的学习中,表现的很努力并且完成作业态度认真,所以得到了老师奖励的小黄衫. 以下是我对于c语言的学习感受与心得. 学习感受与心得 我选择计算机的这个专业,是因为我对计算机的学习很有兴 ...

  10. Mac OS X 上启动 FTP/SFTP server,并设置 log level

    木易小伟的博客| 木易小伟的博客 2013-08-13 5708 阅读 FTP Log SFTP Mac OS 系统配置 1. 启动FTP Server: 命令行下,  sudo -s launch ...