博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
HOWTO Use Python in the web — Python v3.0.1 documentation
阅读量:6236 次
发布时间:2019-06-22

本文共 1807 字,大约阅读时间需要 6 分钟。

mod_python

People coming from PHP often find it hard to grasp how to use Python in the web. Their first thought is mostly because they think that this is the equivalent to mod_php. Actually it is not really. It does embed the interpreter into the Apache process, thus speeding up requests by not having to start a Python interpreter every request. On the other hand, it is by far not “Python intermixed with HTML” as PHP often does. The Python equivalent of that is a template engine. mod_python itself is much more powerful and gives more access to Apache internals. It can emulate CGI, it can work an a “Python Server Pages” mode similar to JSP which is “HTML intermangled with Python” and it has a “Publisher” which destignates one file to accept all requests and decide on what to do then.

But mod_python has some problems. Unlike the PHP interpreter the Python interpreter uses caching when executing files, so when changing a file the whole web server needs to be re-started to update. Another problem ist the basic concept – Apache starts some child processes to handle the requests and unfortunately every child process needs to load the whole Python interpreter even if it does not use it. This makes the whole web server slower. Another problem is that as mod_python is linked against a specific version of libpython, it is not possible to switch from an older version to a newer (e.g. 2.4 to 2.5) without recompiling mod_python. mod_python is also bound to the Apache web server, so programs written for mod_python cannot easily run on other web servers.

These are the reasons why mod_python should be avoided when writing new programs. In some circumstances it might be still a good idea to use mod_python for deployment, but WSGI makes it possible to run WSGI programs under mod_python as well.

转载地址:http://pewia.baihongyu.com/

你可能感兴趣的文章
【zTree】zTree的3.5.26静态树与动态树(实用)
查看>>
《组合数学》
查看>>
文件操作方法大全以及文件打开的其他一些模式sys.stdout.write()就是标准输出到你当前的屏幕 sys.stdout.flush()把内存立即显示到您当前的屏幕...
查看>>
.NET Core 2.0 开源Office组件 NPOI
查看>>
SNF快速开发平台--规则引擎整体介绍及使用说明书
查看>>
vuex笔记
查看>>
【转】采用dlopen、dlsym、dlclose加载动态链接库
查看>>
【树3】满二叉树、完全二叉树、完美二叉树
查看>>
细说mysql replace into
查看>>
ThinkingInJava 学习 之 0000003 控制执行流程
查看>>
glValidateProgram只用于调试
查看>>
Asp.net MVC验证哪些事(2)-- 验证规则总结以及使用
查看>>
二叉排序树 -- 增删查改
查看>>
基于RocketIO的高速串行协议设计与实现
查看>>
多线程学习 ---- 系列教程
查看>>
Wireshark抓包分析TCP协议
查看>>
oracle 11g jdbc jar包在哪个文件目录
查看>>
软件架构是软件功能在技术域上的投影
查看>>
python中的lxml模块
查看>>
分布式强化学习基础概念(Distributional RL )
查看>>