ReyJavik
ReyJavik

Reputation:

How to set up Python in a web server?

Not exactly about programming, but I need help with this.

I'm running a development sever with WampServer. I want to install Python (because I prefer to use Python over PHP), but it seems there isn't an obvious choice. I've read about mod_python and WSGI, and about how the latter is better.

However, from what I gathered (I may be wrong) you have to do more low-level stuff with WSGI than with PHP. So I researched about Django, but it seems too complex for what I want.

So, what recommendations would you give to a newbie in this area?

Again, sorry if this isn't about programming, but it's related, and this seems like a nice place to ask.

Upvotes: 4

Views: 2286

Answers (5)

Silfheed
Silfheed

Reputation: 12191

Werkzeug is a great little python tool (werkzeug) that works with mod_wsgi for creating simple apps that dont need database backends with CMS's, such as calculators .. They've even got a nifty screencast where they create a simple wiki in 30 minutes.

You can always add something like SQLAlchemy/FormAlchemy later on if you eventually do want to have a ORM and CMS.

Avoid mod_python tho, it's got a pretty big memory footprint and it's actually a bit harder to install and set up than mod_wsgi, in my opinion.

Upvotes: 2

S.Lott
S.Lott

Reputation: 391818

Use mod_wsgi to embed Python in Apache. It works very, very well.

"However, from what I gathered (I may be wrong) you have to do more low-level stuff with WSGI than with PHP. So I researched about Django, but it seems too complex for what I want."

  1. If you try to write your entire application as a WSGI-compliant application, directly accessed via mod_wsgi, you will reinvent the wheel.

  2. If you try to write your application in Django, you will have stuff up and running in the space of a few hours. Django is not "too complex" -- it's complete. You don't have to use all of it, but -- for any realistic application -- you'll need most of it. In particular, the built-in admin will save you mountains of programming.

Upvotes: 3

Jarret Hardie
Jarret Hardie

Reputation: 97902

If it's truly a development server you're setting up, and not a machine that will be promoted to production at some point, Django has a built-in development webserver that requires no Apache configuration.

Your observation about the low-level work reflects some of the differences between PHP and Python. PHP is a language designed from the start for the primary purpose of making web pages. Python is a language. Mod_Python and Mod_WSGI give the input to/output from that language a way to live in a web request/response environment. Django adds web-aware framework conveniences.

You mention that python seems too complex for what you want, which rather begs the question: what do you want? :-)

Upvotes: 0

Mike Lowen
Mike Lowen

Reputation: 847

To use python with your Apache server you need to install mod_python the following links should help you out a bit.

Upvotes: 0

James Emerton
James Emerton

Reputation: 4259

Django is not a web server, but a web application framework.

If you want a bare-bones Python webserver capable of some dynamic and some static content, have a look at CherryPy.

Upvotes: 5

Related Questions