Home arrow Python arrow A Brief Look at Mod_Python

A Brief Look at Mod_Python

Python's Apache interpreter is available as an Apache module, mod_python. This module reduces the time it takes to deliver a given page to a client. It is also capable of a great deal more, including interacting with Apache itself in various powerful ways. This article gives you just a taste of what mod_python can do.

TABLE OF CONTENTS:
  1. A Brief Look at Mod_Python
  2. Installing Mod_Python
  3. Getting Started
  4. Creating Handlers and Working with the API
  5. Python Server Pages
By: Peyton McCullough
Rating: starstarstarstarstar / 20
April 25, 2005

print this article
SEARCH DEV SHED

TOOLS YOU CAN USE

advertisement

Introduction

You enter in an address, requesting a page from Apache. It's not just any old page, though. It's a CGI script written in Python. A few moments later, you're staring at the results. However, what exactly does Apache do with your request? As with all CGI scripts, Apache spawns a new process - in this case, the Python interpreter - and then spits out that process' output. It works, but it isn't the fastest way, nor is it the most efficient way.

Other languages have presented different solutions to this problem. Languages such as PHP have embedded their interpreters into Apache. Other languages, such as Perl, offer Apache modules (in Perl's case, mod_perl) that do this. These "other languages" include Python, though not enough people realize this.

This article deals with Python's own module for Apache, mod_python, and the benefits it provides to both man and machine.

A Quick Look at Mod_Python

As I stated eariler, mod_python embeds the Python interpreter into Apache. This reduces the time needed to deliver a given page to a client. Starting the Python interpreter, waiting for it to finish executing, and then catching its output not only takes time, but it takes up valuable resources as well.

This, however, is not the only benefit provided by mod_python. Mod_python can interact with Apache, giving you extraordinary power. You can change the way Apache handles tasks and utilize the Apache API.

Languages that can be embedded straight into HTML, such as PHP, are very popular. CGI does not allow this. However, mod_python does. You've seen Java Server Pages (JSP) and Active Server Pages (ASP); this article will introduce you to Python Server Pages (PSP).

Interesting? Yes. Let's move on.



 
 
>>> More Python Articles          >>> More By Peyton McCullough
 

blog comments powered by Disqus
escort Bursa Bursa escort Antalya eskort
   

PYTHON ARTICLES

- Python Big Data Company Gets DARPA Funding
- Python 32 Now Available
- Final Alpha for Python 3.2 is Released
- Python 3.1: String Formatting
- Python 3.1: Strings and Quotes
- Python 3.1: Programming Basics and Strings
- Tuples and Other Python Object Types
- The Dictionary Python Object Type
- String and List Python Object Types
- Introducing Python Object Types
- Mobile Programming using PyS60: Advanced UI ...
- Nested Functions in Python
- Python Parameters, Functions and Arguments
- Python Statements and Functions
- Statements and Iterators in Python

Developer Shed Affiliates

 


Dev Shed Tutorial Topics: