HOWTO Use Python in the web — Python v3.0.1 documentation

HOWTO Use
Python in the web — Python v3.0.1 documentation

mod_python?

People coming from PHP often find it hard to grasp how to use Python
in the web. Their first thought is mostly mod_python 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.


HOWTO Use Python in the web — Python v3.0.1
documentation,布布扣,bubuko.com

HOWTO Use Python in the web — Python v3.0.1
documentation

时间: 2024-10-18 22:09:40

HOWTO Use Python in the web — Python v3.0.1 documentation的相关文章

DeskPRO.v3.0.0.Enterprise.PHP.NULL 1CD(3维建模 CAM (计算机辅助制造)软件, 致力于尽可能快地建立3维立体模型并将 之转变成CNC数控机床能用的数据)

DDS产品: FEMtools.v3.3.Win32 1CD(振动灵敏度分析软件) FEMtools.v3.3.Win64 1CD Network Analysis Inc产品: Sinda/G.Application.Suite.v2.6 Working-ISO 1CD(有限差分析器软件) ECS产品: FemFat v4.7C 1CD(用于对部件进行疲劳测试的软件.它可为部件的安全使用提供快速可信的解决方案,并可结合NASTRAN,ABAQUS,ANSYS,I-DEAS,MEDINA,PAT

python 启动简单web服务器

有时我们在开发web静态页面时,需要一个web服务器来测试. 这时可以利用python提供的web服务器来实现. 1.在命令行下进入某个目录 2.在该目录下运行命令: python -m SimpleHTTPServer 3.在浏览器打开 http://localhost:8000/路径 这里的路径是相对上面当前目录下的路径.

PSPInstance Object | Web Python

PSPInstance Object | Web Python The PSPInstance object is available to all PSP pages through the psp variable.PSPInstance Object | Web Python,布布扣,bubuko.com

Python写的Web spider(网络爬虫)

Python写的Web spider: <span style="font-size:14px;"># web spider # author vince 2015/7/29 import urllib2 import re # get href content pattern = '<a(?:\\s+.+?)*?\\s+href=\"([h]{1}[^\"]*?)\"' t = set("") # collectio

python下的web服务器模块

python下的web服务模块有三种: BaseHTTPServer: 提供基本的Web服务和处理器类,分别是HTTPServer和BaseHTTPRequestHandler SimpleHTTPServer: 包含执行GET和HEAD请求的SimpleHTTPRequestHandler类 CGIHTTPServer: 包含处理POST请求和执行CGIHTTPRequestHandler类. 下面是CGIHTTPServer类示例: 1 [email protected]:~/cp# tre

Python轻量Web框架Flask使用

http://blog.csdn.net/jacman/article/details/49098819 目录(?)[+] Flask安装 Python开发工具EclipsePyDev准备 Flask项目框架搭建 MVC模式实例开发 登录实例 Python语言近些年越来越火,其特点是开发迅速,语法简单,可移植等.本人就Python3基础语法写了Demo:https://github.com/tangthis/python3_demo,可以当作基础教程和手册查阅. Python Web开发框架常用

python之路-----web应用的创建(python3.4下,django连接mysql)

参考网址: https://github.com/PyMySQL/PyMySQL/ django框架中的一个网站可以包含多个django项目,而一个django项目则包含一组特定的对象,这些对象包括URL的设计.数据库的设计以及其他的一些选项设置. django-admin.py-----它有许多的命令选项,可以通过这些选项来操作项目.其中使用startproject命令选项,可以生成一个项目名的目录,它包括一个基本web应用所需要的文件结构: __init__.py:空文件,主要用来告诉pyt

Python 实现简单 Web 服务器

Python 实现简单 Web 服务器 最近有个需求,就是要创建一个简到要多简单就有多简单的web服务器,目的就是需要一个后台进程用来接收请求然后处理并返回结果,因此就想到了使用python来实现. 首先创建一个myapp.py文件,其中定义了一个方法,所有的请求都会经过此方法,可以在此方法里处理传递的url和参数,并返回结果. def myapp(environ, start_response): status = '200 OK' headers = [('Content-type', 't

python批量同步web服务器代码核心程序

#!/usr/bin/env python #coding:utf8 import os,sys import md5,tab from mysql_co.my_db import set_mysql from ssh_co.ssh_connect import sshd from ssh_co.cfg.config import ssh_message,item_path from file import findfile def my_mysql(): db_file={} my_conne