URN Logo
UNIX Resources » Linux » China Linux Forum » Python 编 程 » 9 » mod_python的问题
announcement 声明: 本页内容为中国Linux论坛的内容镜像,文章的版权以及其他所有的相关权利属于中国Linux论坛和相应文章的作者,如果转载,请注明文章来源及相关版权信息。
Resources
China Linux Forum(finished)
Linux Forum(finished)
FreeBSD China(finished)
linuxforum.net
  业界新闻与评论
  自由软件杂谈
  IT 人生
  Linux软件快递
  翻译作坊
  Linux图书与评论
  GNU Emacs/XEmacs
  Linux 中文环境和中文化
  Linux桌面与办公软件
  Linux 多媒体与娱乐版
  自由之窗Mozilla
  笔记本电脑上的Linux
  Gentoo
  Debian 一族
  网络管理技术
  Linux 安装与入门
  WEB服务器和FTP服务器
  域名服务器和邮件服务器
  Linux防火墙和代理服务器应用
  文件及打印服务器
  技术培训与认证
  Linux内核技术
  Linux 嵌入技术
  Linux设备驱动程序
  Linux 集群技术
  LINUX平台数据库
  系统和网络安全
  CPU 与 编译器
  系统计算研究所专栏
  Linux下的GUI软件开发
  C/C++编程版
  PHP 技 术
  Java&jsp技术
  Shell编程技术
  Perl 编 程
  Python 编 程
  XML/Web Service 技术
  永远的Unix
  FreeBSD世界
   
mod_python的问题
mod_python的问题 - skywind [2005-05-17 17:10 | 249 byte(s)]
 
Re: mod_python的问题 - jhuangjiahua [2005-05-17 22:57 | 1,392 byte(s)]
 
Re: mod_python的问题 - skywind [2005-05-18 09:15 | 477 byte(s)]
 
Re: mod_python的问题 - skywind [2005-05-17 17:25 | 348 byte(s)]
 
Subject: mod_python的问题
Author: skywind    Posted: 2005-05-17 17:10    Length: 249 byte(s)
[Original] [Print] [Top]
配置好了mod_python后,点击测试文件会弹出下载框,下载下来后内容是Hello, World,说明解析成功,但是为什么会弹出下载框而不是直接在浏览器显示呢?
Firefox, Mozilla都是这样,但是Opera却没有问题,可以正常显示。
呵呵
请教
[Original] [Print] [Top]
Subject: Re: mod_python的问题
Author: skywind    Posted: 2005-05-17 17:25    Length: 348 byte(s)
[Original] [Print] [Top]
root@Skywind~# telnet localhost 80
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /test/mptest.py
Hello World!
Connection closed by foreign host.


这是用telnet测试的结果。
[Original] [Print] [Top]
Subject: Re: mod_python的问题
Author: jhuangjiahua    Posted: 2005-05-17 22:57    Length: 1,392 byte(s)
[Original] [Print] [Top]
telnet 返回的好像不对

一般应该先返回类似

HTTP/1.1 200 OK
Date: Tue, 17 May 2005 14:31:18 GMT
Server: Apache/1.3.22
Cache-Control: max-age=1
Expires: Tue, 17 May 2005 14:31:19 GMT
Last-Modified: Mon, 16 May 2005 13:43:00 GMT
ETag: "2d8004-10b1-4288a364"
Accept-Ranges: bytes
Content-Length: 4273
Connection: close
Content-Type: text/html





起码要有 HTTP/1.1 200 OK Content-Type: text/html


不过 , skywind 的系统可能也有问题
本地执行这个脚本是这样的输出

<Skywind> href="mailto:root@Skywind/var/www/test#">root@Skywind/var/www/test# python
mptest.py
<Skywind> Traceback (most recent call last):
<Skywind> File "mptest.py", line 1, in ?
<Skywind> from mod_python import apache
<Skywind> File "/usr/lib/python2.3/site-packages/mod_python/apache.py", line
55, in ?
<Skywind> import _apache
<Skywind> ImportError: No module named _apache

[Original] [Print] [Top]
Subject: Re: mod_python的问题
Author: skywind    Posted: 2005-05-18 09:15    Length: 477 byte(s)
[Original] [Print] [Top]
哎,其实很简单,昨天折腾了好完才发现。
脚本只要这样写就可以了。


from mod_python import apache
def handler(req):
req.content_type = "text/html"
req.write("<h1>Hello World!</h1>")
return apache.OK


需要这一句来设定内容类型
req.content_type = "text/html"
[Original] [Print] [Top]
« Previous thread
pyGTK的简单问题
Python 编 程
9
Next thread »
XML最简单的发问
     

Copyright © 2007 UNIX Resources Network, All Rights Reserved.      About URN | Privacy & Legal | Help | Contact us
备案序号: 京ICP备05006143    webmaster: webmaster@unixresources.net
This page created on 2008-07-17 04:11:12, cost 0.050710201263428 ms.